DEBUG and RELEASE modeI 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())
Working images:


Failed images:


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.
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"