Merge pull request #2773 from SixLabors/js/v4-2769 · SixLabors/ImageSharp@31a4e10 · GitHub
Skip to content

Commit 31a4e10

Browse files
Merge pull request #2773 from SixLabors/js/v4-2769
V4 Correctly break during Png decoding
2 parents 10e9c49 + a217dc8 commit 31a4e10

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

‎src/ImageSharp/Formats/Png/PngDecoderCore.cs‎

Lines changed: 9 additions & 9 deletions

‎src/ImageSharp/Formats/Webp/WebpChunkParsingUtils.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ public static WebpImageInfo ReadVp8XHeader(BufferedReadStream stream, Span<byte>
218218

219219
// 3 reserved bytes should follow which are supposed to be zero.
220220
stream.Read(buffer, 0, 3);
221-
if (buffer[0] != 0 || buffer[1] != 0 || buffer[2] != 0)
222-
{
223-
WebpThrowHelper.ThrowImageFormatException("reserved bytes should be zero");
224-
}
225221

226222
// 3 bytes for the width.
227223
uint width = ReadUInt24LittleEndian(stream, buffer) + 1;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,4 +701,14 @@ public void Decode_BadPalette(string file)
701701
string path = Path.GetFullPath(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, file));
702702
using Image image = Image.Load(path);
703703
}
704+
705+
[Theory]
706+
[WithFile(TestImages.Png.Issue2752, PixelTypes.Rgba32)]
707+
public void CanDecodeJustOneFrame<TPixel>(TestImageProvider<TPixel> provider)
708+
where TPixel : unmanaged, IPixel<TPixel>
709+
{
710+
DecoderOptions options = new() { MaxFrames = 1 };
711+
using Image<TPixel> image = provider.GetImage(PngDecoder.Instance, options);
712+
Assert.Equal(1, image.Frames.Count);
713+
}
704714
}

‎tests/ImageSharp.Tests/TestImages.cs‎

Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)