how loop gif animation ?

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
rafael105
Posts: 3
Joined: 2017-07-16T12:13:24-07:00
Authentication code: 1151

how loop gif animation ?

Post by rafael105 »

Hello :)

I try to create gif animation and i want the animation will start over when all the frames is end, thats mean the gif animation will run non stop.

How can i do that ?

Here is my sample code:

Code: Select all

public string Get()
        {
            using (MagickImageCollection collection = new MagickImageCollection())
            {
                // Add first image and set the animation delay to 100ms
                collection.Add("Snakeware2.gif");
                collection[0].AnimationDelay = 100;

                // Add second image, set the animation delay to 100ms and flip the image
                collection.Add("Snakeware1.gif");
                collection[1].AnimationDelay = 100;
                //collection[1].Flip();
        
                // Optionally reduce colors
                QuantizeSettings settings = new QuantizeSettings();
                settings.Colors = 256;
                collection.Quantize(settings);
                
                // Optionally optimize the images (images should have the same size).
                collection.Optimize();

                // Save gif
                collection.Coalesce();
                string data = collection.ToBase64(MagickFormat.Gif);

                return data;
            }
        }
Post Reply