James Jackson-South
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
12 additions and
9 deletions
-
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
-
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/External
-
BIN
tests/Images/Input/Jpg/issues/issue855-incorrect-colorspace.jpg
|
|
|
@ -401,15 +401,14 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
|
|
|
|
if (this.ComponentCount == 3) |
|
|
|
{ |
|
|
|
if (this.adobe.Equals(default) || this.adobe.ColorTransform == JpegConstants.Adobe.ColorTransformYCbCr) |
|
|
|
{ |
|
|
|
return JpegColorSpace.YCbCr; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.adobe.ColorTransform == JpegConstants.Adobe.ColorTransformUnknown) |
|
|
|
if (!this.adobe.Equals(default) && this.adobe.ColorTransform == JpegConstants.Adobe.ColorTransformUnknown) |
|
|
|
{ |
|
|
|
return JpegColorSpace.RGB; |
|
|
|
} |
|
|
|
|
|
|
|
// Some images are poorly encoded and contain incorrect colorspace transform metadata.
|
|
|
|
// We ignore that and always fall back to the default colorspace.
|
|
|
|
return JpegColorSpace.YCbCr; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.ComponentCount == 4) |
|
|
|
@ -419,7 +418,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
: JpegColorSpace.Cmyk; |
|
|
|
} |
|
|
|
|
|
|
|
JpegThrowHelper.ThrowImageFormatException($"Unsupported color mode. Max components 4; found {this.ComponentCount}"); |
|
|
|
JpegThrowHelper.ThrowImageFormatException($"Unsupported color mode. Supported component counts 1, 3, and 4; found {this.ComponentCount}"); |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -31,9 +31,12 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|
|
|
TestImages.Jpeg.Issues.ExifGetString750Load, |
|
|
|
TestImages.Jpeg.Issues.ExifGetString750Transform, |
|
|
|
|
|
|
|
// LibJpeg can open this despite the invalid desity units.
|
|
|
|
// LibJpeg can open this despite the invalid density units.
|
|
|
|
TestImages.Jpeg.Issues.Fuzz.ArgumentOutOfRangeException825B, |
|
|
|
|
|
|
|
// LibJpeg can open this despite incorrect colorspace metadata.
|
|
|
|
TestImages.Jpeg.Issues.IncorrectColorspace855, |
|
|
|
|
|
|
|
// High depth images
|
|
|
|
TestImages.Jpeg.Baseline.Testorig12bit, |
|
|
|
}; |
|
|
|
|
|
|
|
@ -175,6 +175,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string ExifGetString750Transform = "Jpg/issues/issue750-exif-tranform.jpg"; |
|
|
|
public const string ExifGetString750Load = "Jpg/issues/issue750-exif-load.jpg"; |
|
|
|
public const string IncorrectQuality845 = "Jpg/issues/Issue845-Incorrect-Quality99.jpg"; |
|
|
|
public const string IncorrectColorspace855 = "Jpg/issues/issue855-incorrect-colorspace.jpg"; |
|
|
|
|
|
|
|
public static class Fuzz |
|
|
|
{ |
|
|
|
|
|
|
|
@ -1 +1 @@ |
|
|
|
Subproject commit 94b5a8e11b33ba62c15d1d03f1b8b721468764f1 |
|
|
|
Subproject commit 802725dec2a6b1ca02f9e2f9a4c3f625583d0696 |
Width:
|
Height:
|
Size: 139 KiB
|