Skip to content

JpgExport -> System.ArgumentOutOfRangeException: Index and count must refer to a location within the buffer. Parameter name: bytes #562

@alex-birch

Description

@alex-birch

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

Similar to this issue I raised yesterday but with a different stack trace (thanks for looking at it so quickly!). I'm using ImageSharp to open all these images from mscoco - there are thousands of images and it's doing well on most of them.

Loading and export this image as a Jpg ByteArray causes the following stack trace (again, PNG works okay):

Steps to Reproduce

coco_val2014_000000260238

Unhandled Exception: System.ArgumentOutOfRangeException: Index and count must refer to a location within the buffer. Parameter name: bytes at System.Text.UnicodeEncoding.GetString(Byte[] bytes, Int32 index, Int32 count) at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccDataReader.ReadTextDescriptionTagDataEntry() at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccDataReader.ReadTagDataEntry(IccTagTableEntry info) at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccReader.ReadTagData(IccDataReader reader) at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccProfile.InitializeEntries() at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccWriter.Write(IccProfile profile) at SixLabors.ImageSharp.Formats.Jpeg.GolangPort.JpegEncoderCore.WriteIccProfile(IccProfile iccProfile) at SixLabors.ImageSharp.Formats.Jpeg.GolangPort.JpegEncoderCore.Encode[TPixel](Image1 image, Stream stream)
at WebApplicationBasic.Program.Main(String[] args) in Program.cs:line 17
`

I loaded the image and exported to JPG like so:
var img = SixLabors.ImageSharp.Image.Load<Rgba32>(args[0]); img.ToByteArray(new JpegEncoder());

System Configuration

  • ImageSharp version:
    SixLabors.ImageSharp 1.0.0-beta0003
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on):
    MacOS High Sierra
  • .NET Framework version:
    Dotnet 2.1.3
  • Additional information:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions