You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GIF to WebP conversion issue: animation speed #2619
I have verified that I am running the latest version of ImageSharp
I have verified if the problem exist in both DEBUG and RELEASE mode
I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.1.1
Other ImageSharp packages and versions
ImageSharp.Web 3.1.0
Environment (Operating system, version and so on)
Windows 11
.NET Framework version
.NET 8
Description
When I saw that animated WebP encoding support landed, I started investigating it ASAP.
Our websites are full of animated GIF images, if we can automatically convert these to WebP using ImageSharp.Web (with acceptable quality) we can potentially save a lot of bandwidth.
On a first glance the quality seems fine, but there one problem. The animation speed of most images is way too high.
Steps to Reproduce
Load the attached GIF image with the command format=webp
Images
Image (both original GIF and resulting WebP, I used a .zip file because GitHub does not allow uploading WebP): aug_2022.zip
This seems to be a conversion from a Timespan to an uint that should contain the duration in milliseconds. It uses .Milliseconds but should instead use .TotalMilliseconds.
For a Timespan of 5.5 seconds Milliseconds would be 500, but TotalMilliseconds would be 5500.
Activity
JimBobSquarePants commentedon Dec 12, 2023
This would be a good one for community contribution. It’s just timespan conversion stuff.
marklagendijk commentedon Dec 12, 2023
I looked a bit in the codebase to see if would be something that I might be able to do, and I think I stumbled on the bug:
ImageSharp/src/ImageSharp/Formats/Webp/WebpFrameMetadata.cs
Line 51 in 3fd0d70
This seems to be a conversion from a
Timespanto anuintthat should contain the duration in milliseconds. It uses.Millisecondsbut should instead use.TotalMilliseconds.For a Timespan of 5.5 seconds
Millisecondswould be 500, butTotalMillisecondswould be 5500.JimBobSquarePants commentedon Dec 12, 2023
That'll be it then! My tests all contain sub-second frames so I never picked it up. Thanks for looking! 👍