Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentException on loading JPEG image #646

Closed
3 of 4 tasks
xakep139 opened this issue Jul 3, 2018 · 7 comments · Fixed by #647
Closed
3 of 4 tasks

ArgumentException on loading JPEG image #646

xakep139 opened this issue Jul 3, 2018 · 7 comments · Fixed by #647

Comments

@xakep139
Copy link
Contributor

xakep139 commented Jul 3, 2018

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

I try to load JPEG image that displays normally and loads normally with .NET Framework's System.Drawing.Image.FromFile(). But I get an exception with message:

Data length must be at least 128 to be a valid profile header
Parameter name: data

Stacktrace:

   at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccReader.ReadHeader(Byte[] data)
   at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccProfile.InitializeHeader()
   at SixLabors.ImageSharp.MetaData.Profiles.Icc.IccProfile.CheckIsValid()
   at SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.PdfJsJpegDecoderCore.InitDerivedMetaDataProperties()
   at SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort.PdfJsJpegDecoderCore.Identify(Stream stream)
   at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Identify(Configuration configuration, Stream stream)
   at SixLabors.ImageSharp.Image.InternalIdentity(Stream stream, Configuration config)
   at ImageSharpTest.Program.Main(String[] args) in C:\Users\User\Documents\Visual Studio 2017\Projects\ImageSharpTest\Program.cs:line 15

Steps to Reproduce

Image.Load() or Image.Identify() on image in image.zip

System Configuration

  • ImageSharp version: 1.0.0-dev001615
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on): Windows 10 Enterprise Version 1709 Build 16299
  • Additional information: Visual Studio Professional 2017 Version 15.7.4
  • dotnet --info output:
.NET Core SDK (reflecting any global.json):
 Version:   2.1.301
 Commit:    59524873d6

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.301\

Host (useful for support):
  Version: 2.1.1
  Commit:  6985b9f684
@JimBobSquarePants
Copy link
Member

JPEG or PNG?

@xakep139
Copy link
Contributor Author

xakep139 commented Jul 3, 2018

JPEG. I commented exception details in issue description

@xakep139 xakep139 closed this as completed Jul 3, 2018
@xakep139 xakep139 reopened this Jul 3, 2018
@JimBobSquarePants
Copy link
Member

Ah it's just that you said PNG in the issue description 😄

Looks like we're being overzealous with our ICC check. Time to consult the expert...

@JBildstein What do you think? I would have thought the IsValid() check should just return false?

@xakep139
Copy link
Contributor Author

xakep139 commented Jul 3, 2018

Oh, sorry about that )) I've fixed this typo in description

@xakep139
Copy link
Contributor Author

xakep139 commented Jul 3, 2018

Here's what identify -verbose obj.jpg said about that image:

Image: obj.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1412x940+0+0
  Units: PixelsPerInch
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 1327280
    Red:
      min: 165 (0.647059)
      max: 255 (1)
      mean: 251.862 (0.987693)
      standard deviation: 9.4547 (0.0370773)
      kurtosis: 6.12928
      skewness: -2.78793
    Green:
      min: 3 (0.0117647)
      max: 255 (1)
      mean: 230.773 (0.904991)
      standard deviation: 71.9688 (0.28223)
      kurtosis: 5.46254
      skewness: -2.71341
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 230.704 (0.90472)
      standard deviation: 72.1815 (0.283065)
      kurtosis: 5.46961
      skewness: -2.71455
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 237.779 (0.932468)
      standard deviation: 59.1018 (0.231772)
      kurtosis: 11.1343
      skewness: -3.6302
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1412x940+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 100
  Orientation: TopLeft
  Properties:
    date:create: 2018-07-03T12:22:40+07:00
    date:modify: 2018-07-03T12:22:40+07:00
    dc:format: application/vnd.adobe.photoshop
    exif:ColorSpace: 1
    exif:DateTime: 2007:04:02 03:41:51
    exif:ExifImageLength: 940
    exif:ExifImageWidth: 1412
    exif:ExifOffset: 122
    exif:ExifVersion: 48, 50, 50, 48
    exif:InteroperabilityOffset: 188
    exif:NativeDigest: 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;F6A193E7313BC3C712832ECA4959E350
    exif:Orientation: 1
    exif:PixelXDimension: 1412
    exif:PixelYDimension: 940
    exif:Software: ACD Systems Digital Imaging
    exif:SubSecTime: 437
    exif:thumbnail:InteroperabilityIndex: R98
    exif:thumbnail:InteroperabilityVersion: 48, 49, 48, 48
    exif:YCbCrPositioning: 1
    jpeg:colorspace: 2
    jpeg:sampling-factor: 2x1,1x1,1x1
    photoshop:ColorMode: 3
    photoshop:ICCProfile: sRGB IEC61966-2.1
    signature: 1d80f5e72eafe30a257ad3b1126c82f42e9e2ef7626262922f254abe15107c53
    tiff:NativeDigest: 256,257,258,259,262,274,277,284,530,531,282,283,296,301,318,319,529,532,306,270,271,272,305,315,33432;6A291C54E9FFCECF4CC15E9F47D87555
    tiff:Orientation: 1
    tiff:ResolutionUnit: 2
    tiff:XResolution: 6000000/10000
    tiff:YResolution: 6000000/10000
    xap:CreateDate: 2007-04-01T11:51:04+10:00
    xap:CreatorTool: Adobe Photoshop CS2 Windows
    xap:MetadataDate: 2007-04-02T02:28:07+10:00
    xap:ModifyDate: 2007-04-02T02:28:07+10:00
    xapMM:DocumentID: uuid:D069BA70F2DFDB119A38804E92BD3E0F
    xapMM:InstanceID: uuid:5923632E68E0DB118FC5F0FF17CCB5D6
  Profiles:
    Profile-exif: 228 bytes
    Profile-xmp: 14687 bytes
  Artifacts:
    filename: obj.jpg
    verbose: true
  Tainted: False
  Filesize: 241KB
  Number pixels: 1.327M
  Pixels per second: 66.36MB
  User time: 0.020u
  Elapsed time: 0:01.020
  Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-06-11 http://www.imagemagick.org

@JBildstein
Copy link
Contributor

Fixed it with #647

@JimBobSquarePants
Copy link
Member

You rock! 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants