Browse Source
Merge branch 'main' into bp/tiffwebp
pull/2128/head
Brian Popow
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
23 additions and
0 deletions
-
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
-
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Jpg/issues/Issue2133.jpg
|
|
|
@ -556,6 +556,12 @@ namespace SixLabors.ImageSharp.Formats.Jpeg |
|
|
|
return JpegColorSpace.RGB; |
|
|
|
} |
|
|
|
|
|
|
|
// If these values are 1-3 for a 3-channel image, then the image is assumed to be YCbCr.
|
|
|
|
if (this.Components[2].Id == 3 && this.Components[1].Id == 2 && this.Components[0].Id == 1) |
|
|
|
{ |
|
|
|
return JpegColorSpace.YCbCr; |
|
|
|
} |
|
|
|
|
|
|
|
// 3-channel non-subsampled images are assumed to be RGB.
|
|
|
|
if (this.Components[2].VerticalSamplingFactor == 1 && this.Components[1].VerticalSamplingFactor == 1 && this.Components[0].VerticalSamplingFactor == 1 && |
|
|
|
this.Components[2].HorizontalSamplingFactor == 1 && this.Components[1].HorizontalSamplingFactor == 1 && this.Components[0].HorizontalSamplingFactor == 1) |
|
|
|
|
|
|
|
@ -218,6 +218,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// https://github.com/SixLabors/ImageSharp/issues/2133
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Jpeg.Issues.Issue2133DeduceColorSpace, PixelTypes.Rgba32)] |
|
|
|
public void Issue2133_DeduceColorSpace<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using (Image<TPixel> image = provider.GetImage(JpegDecoder)) |
|
|
|
{ |
|
|
|
image.DebugSave(provider); |
|
|
|
image.CompareToOriginal(provider); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// DEBUG ONLY!
|
|
|
|
// The PDF.js output should be saved by "tests\ImageSharp.Tests\Formats\Jpg\pdfjs\jpeg-converter.htm"
|
|
|
|
// into "\tests\Images\ActualOutput\JpegDecoderTests\"
|
|
|
|
|
|
|
|
@ -272,6 +272,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string Issue2057App1Parsing = "Jpg/issues/Issue2057-App1Parsing.jpg"; |
|
|
|
public const string ExifNullArrayTag = "Jpg/issues/issue-2056-exif-null-array.jpg"; |
|
|
|
public const string ValidExifArgumentNullExceptionOnEncode = "Jpg/issues/Issue2087-exif-null-reference-on-encode.jpg"; |
|
|
|
public const string Issue2133DeduceColorSpace = "Jpg/issues/Issue2133.jpg"; |
|
|
|
|
|
|
|
public static class Fuzz |
|
|
|
{ |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:7be837f931a350906f04542a868c3654a35b4f463ec814939aed3d134c7e56fe |
|
|
|
size 1140 |