You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Exception on loading specific JPEG image
Steps to Reproduce
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
System Configuration
ImageSharp version: 1.0.0-beta0006
Other ImageSharp packages and versions:
Environment (Operating system, version and so on): Windows 10.0.17763
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
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.
Activity
JimBobSquarePants commentedon Apr 12, 2019
@xakep139 Thanks for the detail. Does this happen with the nightlies?
xakep139 commentedon Apr 12, 2019
With
1.0.0-dev002497I getSixLabors.ImageSharp.ImageFormatExceptionwith messageUnsupported color mode. Max components 4; found 3Stacktrace:
JimBobSquarePants commentedon Apr 12, 2019
@xakep139 Thanks, yeah that makes sense.
This is a badly encoded image. The
App14header is incorrectly reporting the colorspace asYccKyet 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.
Handle incorrect colorspace metadata. Fix #882
Handle incorrect colorspace metadata. Fix #882 (#885)
WIP: #12 Synch with master and improve performance of decoders (#986)
Handle incorrect colorspace metadata. Fix SixLabors#882 (SixLabors#885)