imagetools
imagetools copied to clipboard
the ability to convert Gif to Webp animated?
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!
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!
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.
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');
From the constructor page of Sharp website, there are 2 references to animated file in the options
-
options.pages
number number of pages to extract for multi-page input (GIF, WebP, AVIF, TIFF, PDF), use-1
for all pages. (optional, default1
) -
options.animated
boolean Set totrue
to read all frames/pages of an animated image (equivalent of settingpages
to-1
). (optional, defaultfalse
)
Would be great to have an option for webp animated or not in imagetools.
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