Skip to content

Image.Load throws an ArgumentException when loading PNG #937

@jarroda

Description

@jarroda

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

***Possibly related to 849 but separate issue ***
Loading the following PNG (from a Stream or ReadOnlyMemory instance) throws an ArgumentException.

thumb3

Which has the following message:

Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Notes:

  • The issue occurs in beta6 AND the latest dev build dev002749. The issue appears to be closely related to 849, but while that particular case is fixed in the latest dev build, I still get this error for the image linked in this issue.
  • The image renders in Chrome correctly
  • The images are video thumbnails produced by Amazon's Elastic Transcoder service. I have tested multiple thumbnails from various videos with the same result, so it doesn't seem to be a one-off problem with this particular image.

Steps to Reproduce

Use the above image in a FileStream (or any Stream representation).

Load the image (this can be copied/pasted into a .NET Core 2.2 console app and the ImageSharp libraries referenced):

static async Task Main()
{
    try
    {
        // Use http client.
        var client = new HttpClient();

        // Make the request.
        using (Stream stream = await client.GetStreamAsync(
                "https://user-images.githubusercontent.com/561862/54476020-e3ab4c00-47ce-11e9-9cb1-2542507bf23c.png")
            .ConfigureAwait(false))
        {
            Image<Rgba32> image = Image.Load<Rgba32>(stream, new PngDecoder());
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
        throw;
    }
}

System Configuration

  • ImageSharp version: 1.0.0-beta0006 & 1.0.0-dev002749
  • Other ImageSharp packages and versions: None
  • Environment (Operating system, version and so on): Windows 10, Ubuntu 14.04, MacOS 10.13.3
  • .NET Framework version: .NET Core 2.2

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions