Skip to content

System.ArgumentOutOfRangeException for Parameter name: start loading a jpg #578

@ghost

Description

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

When i try to load the attached image, i get the following error

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: start
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
   at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccDataReader.ReadUInt32()
   at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccReader.ReadTagTable(IccDataReader reader)
   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](Image`1 image, Stream stream)
   at SixLabors.ImageSharp.ImageExtensions.Save[TPixel](Image`1 source, String filePath, IImageEncoder encoder)
   at SixLabors.ImageSharp.ImageExtensions.Save[TPixel](Image`1 source, String filePath) 

Steps to Reproduce

using (Image image = SixLabors.ImageSharp.Image.Load(fileName))
{
// note: issue does not happen during Load (e.g. decoding), but rather in the Encoding part when trying to save it
image.Save("bar.jpg"); // Automatic encoder selected based on extension.
}

with this image:

wrong_icc_profile_size

System Configuration

  • ImageSharp version: 1.0.0-beta0003
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): windows 10
  • .NET Framework version: netcoreapp2.0
  • Additional information:

I have tried to check the image with imagemagick identify and JPEGsnoop, both can decode image.

What i have noticed are some weird ICC Profile Sizes, for example at the first Marker: APP2:
The ICC Profile size is stated to be 594832749 bytes, which seems to be wrong.

*** Marker: APP2 (xFFE2) ***
  OFFSET: 0x00000012
  Length          = 32016
  Identifier      = [ICC_PROFILE]
    ICC Profile:
      Marker Number = 1 of 1
        Profile Size                      : 594832749 bytes
        Preferred CMM Type                : 'ᄆᄐ(ᄇ' (0xB1BC28B2)
        Profile Version                   : 6.13.0.11 (0x6D0BA39C)
        Profile Device/Class              : ? (0x2D606CB4) ('-`lᄡ' (0x2D606CB4))
        Data Colour Space                 : ? (0x96F23188) ('ヨ￲1ネ' (0x96F23188))
        Profile connection space (PCS)    : 'lgヒᄅ' (0x6C678BA9)
        Profile creation date             : 13617-27684-33198 14436:27625:30956
        Profile file signature            : ';(kᄋ' (0x3B286BB7)
        Primary platform                  : ? (0x714F3D87) ('qO=ヌ' (0x714F3D87))
        Profile flags                     : 0x6B8C6AC3
        Profile flags                       > Embedded profile
        Profile flags                       > Profile can be used independently of embedded
        Device Manufacturer               : '?ヌkh' (0x3F876B68)
        Device Model                      : 'e3A0' (0x65334130)
        Device attributes                 : 0x6B4A608C_428C6B32
        Device attributes                   > Reflective
        Device attributes                   > Matte
        Device attributes                   > Media polarity = negative
        Device attributes                   > Black & white media
        Rendering intent                  : 0x5CB843A2
        Profile creator                   : 'k�Uh' (0x6B055568)
        Profile ID                        : 0x458D6AFE_541545DA_6AF9532A_46166AF5

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