diff --git a/codecov.yml b/codecov.yml index 3941f7ff9a..833fc0a51a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -5,3 +5,7 @@ codecov: # https://github.com/codecov/support/issues/363 # https://docs.codecov.io/docs/comparing-commits allow_coverage_offsets: true + + # Avoid Report Expired + # https://docs.codecov.io/docs/codecov-yaml#section-expired-reports + max_report_age: off diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 722c9c8992..98dbddb481 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -274,9 +274,8 @@ namespace SixLabors.ImageSharp.Formats.Gif } // Could be XMP or something else not supported yet. - // Back up and skip. - this.stream.Position -= appLength + 1; - this.SkipBlock(appLength); + // Skip the subblock and terminator. + this.SkipBlock(subBlockSize); return; } diff --git a/src/ImageSharp/Formats/Gif/GifMetadata.cs b/src/ImageSharp/Formats/Gif/GifMetadata.cs index b00db6752b..5fe86c4dd3 100644 --- a/src/ImageSharp/Formats/Gif/GifMetadata.cs +++ b/src/ImageSharp/Formats/Gif/GifMetadata.cs @@ -36,10 +36,10 @@ namespace SixLabors.ImageSharp.Formats.Gif /// /// Gets or sets the number of times any animation is repeated. /// - /// 0 means to repeat indefinitely, count is set as play n + 1 times + /// 0 means to repeat indefinitely, count is set as repeat n-1 times. Defaults to 1. /// /// - public ushort RepeatCount { get; set; } + public ushort RepeatCount { get; set; } = 1; /// /// Gets or sets the color table mode. diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs index cf8918680a..578dca0ce0 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifMetadataTests.cs @@ -23,6 +23,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif { TestImages.Gif.Ratio4x1, 4, 1, PixelResolutionUnit.AspectRatio } }; + public static readonly TheoryData RepeatFiles = + new TheoryData + { + { TestImages.Gif.Cheers, 0 }, + { TestImages.Gif.Receipt, 1 }, + { TestImages.Gif.Rings, 1 } + }; + [Fact] public void CloneIsDeep() { @@ -136,5 +144,35 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif Assert.Equal(yResolution, meta.VerticalResolution); Assert.Equal(resolutionUnit, meta.ResolutionUnits); } + + [Theory] + [MemberData(nameof(RepeatFiles))] + public void Identify_VerifyRepeatCount(string imagePath, uint repeatCount) + { + var testFile = TestFile.Create(imagePath); + using (var stream = new MemoryStream(testFile.Bytes, false)) + { + var decoder = new GifDecoder(); + IImageInfo image = decoder.Identify(Configuration.Default, stream); + GifMetadata meta = image.Metadata.GetGifMetadata(); + Assert.Equal(repeatCount, meta.RepeatCount); + } + } + + [Theory] + [MemberData(nameof(RepeatFiles))] + public void Decode_VerifyRepeatCount(string imagePath, uint repeatCount) + { + var testFile = TestFile.Create(imagePath); + using (var stream = new MemoryStream(testFile.Bytes, false)) + { + var decoder = new GifDecoder(); + using (Image image = decoder.Decode(Configuration.Default, stream)) + { + GifMetadata meta = image.Metadata.GetGifMetadata(); + Assert.Equal(repeatCount, meta.RepeatCount); + } + } + } } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 099d501a90..16c570d63d 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -353,6 +353,7 @@ namespace SixLabors.ImageSharp.Tests public const string Rings = "Gif/rings.gif"; public const string Giphy = "Gif/giphy.gif"; public const string Cheers = "Gif/cheers.gif"; + public const string Receipt = "Gif/receipt.gif"; public const string Trans = "Gif/trans.gif"; public const string Kumin = "Gif/kumin.gif"; public const string Leo = "Gif/leo.gif"; diff --git a/tests/Images/Input/Gif/receipt.gif b/tests/Images/Input/Gif/receipt.gif new file mode 100644 index 0000000000..ce800a8197 --- /dev/null +++ b/tests/Images/Input/Gif/receipt.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bac212852eee73f3c29f30be0be375e5caccbe86e5f4adfaa8c0a7a3673a91ab +size 50686