Skip to content

Images are overlapping in gif #1895

@paulius-petkus

Description

@paulius-petkus

Magick.NET version

14.8.0

Environment (Operating system, version and so on)

Windows

Description

I am creating gif image from 2 source images. Source images are overlapping in the result gif:

Image

Steps to Reproduce

This is my .Net 8 code snippet:

            using (var collection = new MagickImageCollection())
            {
                var gifAdded = false;
                List<string> sourceFiles = [@"C:\Users\petku\Downloads\GifImages\619971-1E.png", @"C:\Users\petku\Downloads\GifImages\619971-2E.png"];
                foreach (var conversionSourceFile in sourceFiles)
                {
                    collection.AddRange(conversionSourceFile);
                }

                foreach (var image in collection)
                {
                    if (Conversion.ToBoolean(ImageParameter.PersistAnimation()) && gifAdded)
                    {
                    }
                    else
                    {
                        image.AnimationIterations = 0;
                        image.AnimationDelay = 100;
                    }


                    var imageResolution = 200;
                    var height = 0;
                    var width = 0;
                    var scaleImage = false;
                    var scaleProportions = true;
                    var scaleIfLarger = false;


                    image.Density = new Density(imageResolution, imageResolution, DensityUnit.PixelsPerInch);
                    
                }
                
                collection.Coalesce();
                collection.Optimize();
                collection.OptimizeTransparency();

                using (var fs = File.Create(Conversion.DestinationLocation + @"\result.gif"))
                {
                    collection.Write(fs, MagickFormat.Gif);
                }
            }

Images

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions