Skip to content

GIF to WebP conversion issue: animation speed #2619

Description

@marklagendijk

Prerequisites

  • I have written a descriptive issue title
  • 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

  1. 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

Activity

  1. JimBobSquarePants commented on Dec 12, 2023

    @JimBobSquarePants
    Member

    This would be a good one for community contribution. It’s just timespan conversion stuff.

  2. marklagendijk commented on Dec 12, 2023

    @marklagendijk
    ContributorAuthor

    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:

    FrameDelay = (uint)metadata.Duration.Milliseconds,

    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.

  3. JimBobSquarePants commented on Dec 12, 2023

    @JimBobSquarePants
    Member

    That'll be it then! My tests all contain sub-second frames so I never picked it up. Thanks for looking! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions