imazen / imageflow

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow
https://docs.imageflow.io/
GNU Affero General Public License v3.0
4.14k stars 140 forks source link

Lost animation when converting from GIF to WebP #606

Open NiJeTi opened 2 years ago

NiJeTi commented 2 years ago

Using library to reduce incoming images size. Converting incoming GIFs to WebP removes animation.

Used code:

public async Task<MemoryStream> ConvertStreamAsync(Stream input, CancellationToken cancellationToken)
{
    Log.Debug("Converting image stream");

    using var imagesProcessor = new ImageJob();
    var output = new MemoryStream();

    await imagesProcessor
       .Decode(input, false)
       .EncodeToStream(output, false, new WebPLosslessEncoder())
       .Finish()
       .WithCancellationToken(cancellationToken)
       .InProcessAsync();

    output.Position = 0;

    Log.Debug("Done converting image stream");

    return output;
}

input stream can contain JPEG, PNG, WebP and GIF

NiJeTi commented 2 years ago

It also increased in size image

lilith commented 2 years ago

I'm not sure we support animated WebP at this time, but I will see what I can do.