Vips::Error VipsForeignSave in gif images (not a known file format)
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!
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.
Thanks for the answer @brandoncc 🙂
I tried forking the repo and doing a new build installing imagemagick as a dependency (also updating to [email protected]) 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.
👋 @mllocs and @brandoncc
I made this change on our fork and the net increase inside the heroku-20 stack build was +23.5 KB
https://github.com/betterup/heroku-buildpack-vips/pull/1/commits/dd2ab92cbd26233de42cbda847cbbeb5d61093a2
@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
libvips 8.12 has a new built-in GIF saver, so you no longer need imagemagick for this feature.
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
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.
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.
Yeah, I had real trouble adding cgif via aptfile if anyone knows how please share the result.
@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).
Yes, you need to build from source (it's very simple) since cgif hasn't been packaged yet (as far as I know).
And just to push this verification a little further, it needs to be built/available during the build of libvips. Is that correct, John?
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.
You are the best, John. Thank you again.
Hi @brandoncc any chance of updating the buildpack? Many thanks.
Sorry I haven't pushed any changes. I actually did the upgrades but I haven't had time to test them. Maybe I'll push to a PR so others can do some testing too. I'm slightly fearful of breaking things that already work.
On Thu, Mar 10, 2022, 2:08 AM Matthew Ford @.***> wrote:
Hi @brandoncc https://github.com/brandoncc any chance of updating the buildpack? Many thanks.
— Reply to this email directly, view it on GitHub https://github.com/brandoncc/heroku-buildpack-vips/issues/16#issuecomment-1063882667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEEZZNXFXHRAQCRDHIPO2DU7HC3PANCNFSM4Z3MLU5A . You are receiving this because you were mentioned.Message ID: @.***>
@brandoncc happy to test if there is a branch/pr?
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.