libvips / lua-vips

Lua binding for the libvips image processing library
MIT License
125 stars 10 forks source link

Can't save image as a GIF? #39

Closed RiskoZoSlovenska closed 2 years ago

RiskoZoSlovenska commented 3 years ago

Hello, I've recently been playing around with libvips and all has gone smoothly save for one issue: I can't seem to be able to save a GIF image back to file after reading it; I get a VipsForeignSave: "test2.gif" is not a known file format error.

That error is being raised by this code:

local vips = require("vips")

local image = vips.Image.new_from_file("test.gif", {n = -1})
image:write_to_file("test2.gif")

Additionally, I also tried running a code sample provided in a different issue, only to get the same result.

Reading the GIF and saving it to other formats (PNG) works. I've also tried to use magicksave()

local vips = require("vips")

local image = vips.Image.new_from_file("test.gif", {n = -1})
image:magicksave("test2.gif")

but that gives me a no such operation error.

Is this a limitation of the Lua binding? Am I doing something wrong?

My libvips version is 8.10.2.

Thanks in advance!

jcupitt commented 3 years ago

Hi @RiskoZoSlovenska, it sounds like your libvips has been built without libmagick support.

You'll need to install imagemagick-dev and then reconfigure and rebuild libvips.

RiskoZoSlovenska commented 2 years ago

Apologies for the absurdly long radio silence. I see a gif saver has been added at some point since I asked this (yay!), and as such I no longer have a problem. Thanks!

jcupitt commented 2 years ago

Yes, libvips 8.12 has its own GIF saver now. There are some notes and a benchmark here:

https://www.libvips.org/2021/11/14/What's-new-in-8.12.html