DEBUG and RELEASE mode
Exception on loading specific JPEG image
using (Image.Load(@"D:\error.jpeg")) { }
with image error.zip will cause a NullReferenceException with message: Object reference not set to an instance of an object.
Here's the stacktrace:
at SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.JpegFrame.Dispose()
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.Dispose()
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Decode[TPixel](Configuration configuration, Stream stream)
at SixLabors.ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
at SixLabors.ImageSharp.Image.WithSeekableStream[T](Configuration config, Stream stream, Func`2 action)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, String path)
at ImageSharpTest.Program.Main(String[] args) in C:\Users\user\Documents\ImageSharpTest\Program.cs:line 13
@xakep139 Thanks for the detail. Does this happen with the nightlies?
With 1.0.0-dev002497 I get SixLabors.ImageSharp.ImageFormatException with message Unsupported color mode. Max components 4; found 3
Stacktrace:
at SixLabors.ImageSharp.Formats.Jpeg.JpegThrowHelper.ThrowImageFormatException(String errorMessage)
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.DeduceJpegColorSpace()
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ProcessStartOfFrameMarker(Int32 remaining, JpegFileMarker& frameMarker, Boolean metadataOnly)
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ParseStream(Stream stream, Boolean metadataOnly)
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.Decode[TPixel](Stream stream)
at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Decode[TPixel](Configuration configuration, Stream stream)
at SixLabors.ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
at SixLabors.ImageSharp.Image.WithSeekableStream[T](Configuration config, Stream stream, Func`2 action)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, String path)
at ImageSharpTest.Program.Main(String[] args) in C:\Users\user\Documents\ImageSharpTest\Program.cs:line 13
@xakep139 Thanks, yeah that makes sense.
This is a badly encoded image. The App14 header is incorrectly reporting the colorspace as YccK yet there are only 3 color components. We throw, but since, this is an optional marker we are being too aggressive in doing so.
We should actually invert our approach and base our colorspace detection on defaults based on the component count and only change from the default if the component count is correct for any additonal metadata supplied.