imagetools icon indicating copy to clipboard operation
imagetools copied to clipboard

the ability to convert Gif to Webp animated?

Open EnderPicture opened this issue 3 years ago • 5 comments

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!

EnderPicture avatar Jan 31 '22 03:01 EnderPicture

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!

JonasKruckenberg avatar Feb 04 '22 08:02 JonasKruckenberg

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.

millette avatar Feb 22 '22 17:02 millette

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');

EnderPicture avatar Mar 09 '22 05:03 EnderPicture

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, default 1)
  • options.animated boolean Set to true to read all frames/pages of an animated image (equivalent of setting pages to -1). (optional, default false)

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

TomBor avatar Mar 21 '22 15:03 TomBor

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

Amerlander avatar Sep 02 '22 00:09 Amerlander