Skip to content

Commit 9c9854d

Browse files
Merge pull request #2674 from SixLabors/js/fix-2666
Don't skip reading data for animation chunks on identify.
2 parents a11c5e7 + 83ecbdb commit 9c9854d

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/ImageSharp/Formats/Png/PngDecoderCore.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,13 @@ private bool TryReadChunk(Span<byte> buffer, out PngChunk chunk)
18711871
PngChunkType type = this.ReadChunkType(buffer);
18721872

18731873
// If we're reading color metadata only we're only interested in the IHDR and tRNS chunks.
1874-
// We can skip all other chunk data in the stream for better performance.
1875-
if (this.colorMetadataOnly && type != PngChunkType.Header && type != PngChunkType.Transparency && type != PngChunkType.Palette)
1874+
// We can skip most other chunk data in the stream for better performance.
1875+
if (this.colorMetadataOnly &&
1876+
type != PngChunkType.Header &&
1877+
type != PngChunkType.Transparency &&
1878+
type != PngChunkType.Palette &&
1879+
type != PngChunkType.AnimationControl &&
1880+
type != PngChunkType.FrameControl)
18761881
{
18771882
chunk = new PngChunk(length, type);
18781883
return true;

tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,11 @@ public void Binary_PrematureEof()
665665
Assert.True(eofHitCounter.EofHitCount <= 3);
666666
Assert.Equal(new Size(200, 120), eofHitCounter.Image.Size);
667667
}
668+
669+
[Fact]
670+
public void Decode_Issue2666()
671+
{
672+
string path = Path.GetFullPath(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImages.Png.Issue2666));
673+
using Image image = Image.Load(path);
674+
}
668675
}

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public static class Png
7373
public const string DisposeBackgroundRegion = "Png/animated/15-dispose-background-region.png";
7474
public const string DisposePreviousFirst = "Png/animated/12-dispose-prev-first.png";
7575
public const string BlendOverMultiple = "Png/animated/21-blend-over-multiple.png";
76+
public const string Issue2666 = "Png/issues/Issue_2666.png";
7677

7778
// Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
7879
public const string Filter0 = "Png/filter0.png";
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)