JonasKruckenberg / imagetools

Load and transform images using a toolbox :toolbox: of custom import directives!
MIT License
935 stars 59 forks source link

the ability to convert Gif to Webp animated? #317

Open EnderPicture opened 2 years ago

EnderPicture commented 2 years ago

Hi,

I see that it is possible for Sharp to convert Gif to animated Webp files in their doc. Is it possible in image tools? currently, the conversion works but only to a static image.

Thanks!

JonasKruckenberg commented 2 years ago

Your link seems to just go to their homepage and I couldn't find the specific option you mentioned.

Maybe you can provide a quick reproduction with a gif that would be converted into an animated webp normally but doesn't get converted when using imagetools so I can can check it out!

millette commented 2 years ago

I think he's referring to options.pages.

number of pages to extract for multi-page input (GIF, WebP, AVIF, TIFF, PDF), use -1 for all pages.

EnderPicture commented 2 years ago

Sorry for the delay, I was referring to this section

// Convert an animated GIF to an animated WebP
await sharp('in.gif', { animated: true }).toFile('out.webp');
TomBor commented 2 years ago

From the constructor page of Sharp website, there are 2 references to animated file in the options

Would be great to have an option for webp animated or not in imagetools.

Amerlander commented 2 years ago

Any plans to implements this?

I guess line 6 in util.ts has to be extended to receive the option to enable animations:

return sharp(path, { animated: true })

https://github.com/JonasKruckenberg/imagetools/blob/c70b97e22256550aa9eac4bb7c7e9063c881ac00/packages/core/src/util.ts#L6