Imagesharp: System.ArgumentOutOfRangeException thrown during Metadata.Profiles.Icc.IccDataReader.ReadDateTime()

Created on 24 Feb 2020  路  9Comments  路  Source: SixLabors/ImageSharp

Prerequisites

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

Description

I am processing a set of images, all of which I do not know anything about as I am parsing HTML snippets for a migration of one integration to another. Some of the images I know are from as far back as 2003. Anyway, when I call Image.Load(imageBytes) on some of these images I get this exception:

System.ArgumentOutOfRangeException: 'Year, Month, and Day parameters describe an un-representable DateTime.

Here is a partial stack trace:

System.Private.CoreLib.dll!System.DateTime.DateToTicks(int year, int month, int day) Line 656 C# System.Private.CoreLib.dll!System.DateTime.DateTime(int year, int month, int day, int hour, int minute, int second, System.DateTimeKind kind) Line 226 C# SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Metadata.Profiles.Icc.IccDataReader.ReadDateTime() Unknown SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Metadata.Profiles.Icc.IccReader.ReadHeader(SixLabors.ImageSharp.Metadata.Profiles.Icc.IccDataReader reader) Unknown SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Metadata.Profiles.Icc.IccReader.ReadHeader(byte[] data) Unknown SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Metadata.Profiles.Icc.IccProfile.InitializeHeader() Unknown SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Metadata.Profiles.Icc.IccProfile.Header.get() Unknown SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Metadata.Profiles.Icc.IccProfile.CheckIsValid() Unknown SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.InitIccProfile() Unknown

I don't care if the file is corrupt or unusable by ImageSharp as I can easily skip and forget about it. However, I cannot seem to workout how to avoid the exception being thrown, I have a try-catch around the Image.Load() and the following check prior to calling it:

if (format == null || meta.Metadata.IccProfile == null || !meta.Metadata.IccProfile.CheckIsValid())

Steps to Reproduce

Working images:

example-1
example-2

Failed images:

example-3
example-4

System Configuration

  • ImageSharp version: v1.0.0-beta0007
  • Windows 10 Pro N (Version 1909, OS Build 18636.657)
  • .NET Framework version: .NET Core 3.1
bug icc

Most helpful comment

@brianpopow Github can mess with the images when they are uploaded. @rhysstubbs can you please upload the images inside a zip to prevent github being "helpful"

All 9 comments

I can provide example images if required.

@rhysstubbs that would be helpful! We hardly can reproduce codec-related issues without them.

Just to add to my comment "I can easily skip and forget" - I am fine with this, however, I have just tested with a much larger set of images and 674 failed with only 68 succeeding. All the failures were due to the above issue. @antonfirsov I will attach a few now.

I have attached 4 images, all .jpg, 2 working and 2 failures.

@rhysstubbs thanks!

@rhysstubbs i have tried to reproduce your issue, but the images you provided are loading fine with ImageSharp v1.0.0-beta0007.

It seems neither 75145578-7e0f5180-56f9-11ea-8b19-490d7fed9139.jpg nor 75145581-7f407e80-56f9-11ea-8e56-8c13bd21cbb2.jpg have actually a Icc profile.

@brianpopow Github can mess with the images when they are uploaded. @rhysstubbs can you please upload the images inside a zip to prevent github being "helpful"

@tocsoft Good point, here are the same images in a zip
failed-images.zip
successful-images.zip

@rhysstubbs: i still have problems reproducing the issue. The images you have provided in the failed-images zip file: example-3.jpg and example-4.jpg can be loaded with ImageSharp v1.0.0-beta0007.
They both do not contain an ICC profile, so i guess they are not the ones which are failing.

Since we've been unable to replicate the issues with the supplied images I'm going to close this.

@rhysstubbs feel free to request that we reopen it once you have identified the problematic images.

Was this page helpful?
0 / 5 - 0 ratings