SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.26k stars 844 forks source link

Loading image with DecoderOptions { MaxFrames = 1 } loads multiple frames for attached png file #2752

Closed danbystrom closed 3 hours ago

danbystrom commented 4 weeks ago

Prerequisites

ImageSharp version

3.1.4

Other ImageSharp packages and versions

-

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

net7.0

Description

Loading an image with the following statement: using var img = await SixLabors.ImageSharp.Image.LoadAsync(new DecoderOptions { MaxFrames = 1 }, fileStream); should just load one frame, which is does for all images I have tested on, EXCEPT the attached one, where it imports all 42 frames.

Steps to Reproduce

Load the attached "duck.png" like this:

  using var fileStream = File.OpenRead(@"c:\temp\duck.png");
  using var img = await SixLabors.ImageSharp.Image.LoadAsync(new DecoderOptions { MaxFrames = 1 }, fileStream);
  Assert.AreEqual(1, img.Frames.Count);

Images

duck