-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animated Images Support #95
Comments
Decision could also be made based on the source image extension (as read in L331) , to set |
Hi @david-zacharias @dli7319, I also played around with the animated option in sharp, but the images always come out static. Feel welcome to try your luck; I haven't found a way to optimize the animated images in size (and neither does Next.js) |
Thanks for the example of using unoptimized. In my own experiments, adding animated to your code seems to work perfectly, albeit with very slow performance: Nevertheless, it would also be nice if unoptimized could be automatically applied for animated images like in next.js in case someone doesn't want animated images to be optimized: |
Interesting that it works for you. When I only change this line in the code const transformer = sharp(imageBuffer, { animated: true }); the generated image is not animated anymore. Did you do something else that I am missing? Regarding your second point: The unfortunate thing is that the isAnimated package is a server package and on the client side where I would need to set the unoptimized prop, we cannot run such a check. |
I put all the changes I made in that commit and just ran |
I just tested using your static noise gif and animated png (dli7319@39af8a6). |
Thanks, I just came to the same conclusion. I was irritated as the webp version did not animate in the file preview, but they do in the browser. |
Currently, animated images (WebP, GIF) are turned into static images.
Based on https://sharp.pixelplumbing.com/api-constructor, it looks like animated images support could be enabled by simply adding
{ animated: true }
tonext-image-export-optimizer/src/optimizeImages.js
Line 417 in ddb110c
It would be awesome if this functionality could be exposed through an environment variable.
Note that next/image claims to bypass animated images.
The text was updated successfully, but these errors were encountered: