zerodevx / svelte-img

High-performance responsive/progressive images for SvelteKit
https://zerodevx.github.io/svelte-img/
ISC License
321 stars 11 forks source link

Enable animations for GIF files #12

Open neil3000 opened 1 year ago

neil3000 commented 1 year ago

Could it be possible to add support for animations, maybe by adding another url param, like ?anim?

Sharp already provides a way to make the conversion from animated to GIF to animated WebP, and currently the conversion technically works but returns a static image.

Sharp has this option to allow such conversion:

return sharp(path, { animated: true })

You could also switch to a branch of imagetools that supports this parameter, such as: https://github.com/JonasKruckenberg/imagetools/pull/454

zerodevx commented 1 year ago

Seems like there's activity in the related imagetools PR, so let's wait for that to land first.

neil3000 commented 1 year ago

I think this PR has become inactive again (for 40 days?) :/

Moreover I think it's easier to just add the {animated: true}. Indeed in the PR I proposed a parameter option because it could generate animated images for formats such as PDFs (when the dev could have just wanted a static image of the first page), which I believe is more an edge-case than animated images as a whole :)

zerodevx commented 1 year ago

Just thinking out loud - are animated images supposed to work with LQIP? If yes, how does it look like?

neil3000 commented 1 year ago

I think it could stay the way it is, that is generating a lower quality image of the first frame of the animated image?

That way it would be similar to how videos work, showing a preview image. Then once it loads, it shows the animated image.