diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index 588f652548..cbaed758dc 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. using System.IO; +using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.PixelFormats; @@ -132,6 +133,30 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif } } + [Theory] + [WithFile(TestImages.Gif.GlobalQuantizationTest, PixelTypes.Rgba32)] + public void Encode_GlobalPalette_QuantizeMultipleFrames(TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + using Image image = provider.GetImage(); + + var encoder = new GifEncoder() + { + ColorTableMode = GifColorTableMode.Global + }; + + string testOutputFile = provider.Utility.SaveTestOutputFile( + image, + "gif", + encoder, + appendPixelTypeToFileName: false, + appendSourceFileOrDescription: false); + + IImageDecoder referenceDecoder = TestEnvironment.GetReferenceDecoder(testOutputFile); + using var encoded = Image.Load(testOutputFile, referenceDecoder); + ValidatorComparer.VerifySimilarity(image, encoded); + } + [Fact] public void NonMutatingEncodePreservesPaletteCount() { diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 141a8d1c38..e18ef3eef5 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -396,6 +396,7 @@ namespace SixLabors.ImageSharp.Tests public const string Ratio4x1 = "Gif/base_4x1.gif"; public const string Ratio1x4 = "Gif/base_1x4.gif"; public const string LargeComment = "Gif/large_comment.gif"; + public const string GlobalQuantizationTest = "Gif/GlobalQuantizationTest.gif"; // Test images from https://github.com/robert-ancell/pygif/tree/master/test-suite public const string ZeroSize = "Gif/image-zero-size.gif"; diff --git a/tests/Images/Input/Gif/GlobalQuantizationTest.gif b/tests/Images/Input/Gif/GlobalQuantizationTest.gif new file mode 100644 index 0000000000..8fa4e7f99c --- /dev/null +++ b/tests/Images/Input/Gif/GlobalQuantizationTest.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c67df4b08561c14054ed911e6cfc99f1fc726b32e2c7a5e2dbb8392e24109b5a +size 101868