Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vips::Error VipsForeignSave in gif images (not a known file format) #16

Closed
mllocs opened this issue Mar 26, 2021 · 17 comments
Closed

Vips::Error VipsForeignSave in gif images (not a known file format) #16

mllocs opened this issue Mar 26, 2021 · 17 comments

Comments

@mllocs
Copy link

mllocs commented Mar 26, 2021

Hello,

I'm using this buildpack in a Rails applications in Heroku. I managed to make it work but I'm having issues with gif images.

I get the error when dealing with gif images:

Vips::Error
VipsForeignSave: "/tmp/image_processing20210326-4-5xvus3.gif" is not a known file format

I found this thread exposing a similar issue and the proposed solution is to rebuild libvips with libmagick support.

I there a way to do that using this buildpack or should I do a fork instead?

Thanks!

@mllocs mllocs changed the title VipsForeignSave in gif images (not a known file format) Vips::Error VipsForeignSave in gif images (not a known file format) Mar 26, 2021
@brandoncc
Copy link
Contributor

Thanks for opening this issue. I'll look into this and see if it looks doable. I don't have a problem doing this as long as it doesn't cause bloat. I'm not sure how much space usage libmagick introduces (the name is reminiscent of imagemagick which is what makes me wonder).

If you would like, you are welcome to fork the repo and add this to the build. Then we can compare the build sizes.

If you would rather I do the test, I'll try to work on it this weekend.

@mllocs
Copy link
Author

mllocs commented Mar 31, 2021

Thanks for the answer @brandoncc 🙂

I tried forking the repo and doing a new build installing imagemagick as a dependency (also updating to libvips@8.10.6) but I had no success, I still get the same error in Heroku when trying to convert gif images.

I suspect I didn't configure the build properly. JCupitt mentioned to add libmagick support but I'm not quite sure how to do that in the buildpack.

@jordanbyron
Copy link

👋 @mllocs and @brandoncc

I made this change on our fork and the net increase inside the heroku-20 stack build was +23.5 KB

betterup@dd2ab92

@brandoncc if that seems like an acceptable increase in size I'd be happy to submit a PR with the updated configuration and builds.

It might be worth pointing out that the libvips install guides flag the increased attack surface by including Imagemagick in the build.

ImageMagick, or optionally GraphicsMagick

If you are going to be using libvips with untrusted images, perhaps in a web server, for example, you should consider the security implications of enabling a package with such a large attack surface.

Source: https://libvips.github.io/libvips/install.html

@jcupitt
Copy link
Contributor

jcupitt commented Dec 30, 2021

libvips 8.12 has a new built-in GIF saver, so you no longer need imagemagick for this feature.

@matthewford
Copy link

libvips 8.12 has a new built-in GIF saver, so you no longer need imagemagick for this feature.

Hi, thanks for this build pack, however I still see the original issue mentioned on libvips 8.12.1-Wed

@jcupitt
Copy link
Contributor

jcupitt commented Feb 25, 2022

Sorry, I misspoke, libvips has a new GIF saver, but it needs cgif for the actual encode. This should be added to the build and imagemagick removed.

https://github.com/dloebl/cgif

(cgif is only v0.2, but it's being used by quite a few large sites (like shopify), so (imo) it's fine)

libvips 8.12.1 didn't fall back to imagemagick correctly for GIF, but 8.12.2 fixes this.

@brandoncc
Copy link
Contributor

Thank you for letting us know about that new GIF saver, John!

I'll work on adding this over the weekend.

Sorry for the delay on this issue, everyone.

@matthewford
Copy link

Yeah, I had real trouble adding cgif via aptfile if anyone knows how please share the result.

@brandoncc
Copy link
Contributor

@jcupitt I'm guessing that I need to add cgif to the build script, rather than just installing it on the server after the fact. Can you confirm that?

@matthewford if John confirms, then this is the reason. I'll build it with cgif this weekend (likely tomorrow).

@jcupitt
Copy link
Contributor

jcupitt commented Feb 25, 2022

Yes, you need to build from source (it's very simple) since cgif hasn't been packaged yet (as far as I know).

@brandoncc
Copy link
Contributor

And just to push this verification a little further, it needs to be built/available during the build of libvips. Is that correct, John?

@jcupitt
Copy link
Contributor

jcupitt commented Feb 25, 2022

That's right -- check the messages from configure. I would add libspng as well, if you're revising this stuff. It's quite a bit faster and smaller than libpng.

I see:

...
PNG load/save with libspng:             yes
 (requires spng 0.7 or later)
PNG load/save with libpng:              no
 (requires libpng-1.2.9 or later)
selected quantisation package:          imagequant
...
GIF save with cgif:                     yes
 (requires cgif and a quantisation package)
...

You can use vips --vips-config after building to check all the configured packages.

@brandoncc
Copy link
Contributor

You are the best, John. Thank you again.

@matthewford
Copy link

Hi @brandoncc any chance of updating the buildpack? Many thanks.

@brandoncc
Copy link
Contributor

brandoncc commented Mar 10, 2022 via email

@matthewford
Copy link

@brandoncc happy to test if there is a branch/pr?

@brandoncc
Copy link
Contributor

brandoncc commented Sep 18, 2023

I'm sorry for the extremely long delay on this issue. Saving GIFs should work now https://github.com/brandoncc/heroku-buildpack-vips/blob/4d51d1cb1546ace27ccfd8aa928c017c2cfd4a3d/build/configurations/heroku-22.config.log#L38

If there is any further trouble, feel free to re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants