File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed
src/ImageSharp/Formats/Jpeg Expand file tree Collapse file tree 4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -530,6 +530,12 @@ private JpegColorSpace DeduceJpegColorSpace(byte componentCount)
530
530
return JpegColorSpace . RGB ;
531
531
}
532
532
533
+ // If these values are 1-3 for a 3-channel image, then the image is assumed to be YCbCr.
534
+ if ( this . Components [ 2 ] . Id == 3 && this . Components [ 1 ] . Id == 2 && this . Components [ 0 ] . Id == 1 )
535
+ {
536
+ return JpegColorSpace . YCbCr ;
537
+ }
538
+
533
539
// 3-channel non-subsampled images are assumed to be RGB.
534
540
if ( this . Components [ 2 ] . VerticalSamplingFactor == 1 && this . Components [ 1 ] . VerticalSamplingFactor == 1 && this . Components [ 0 ] . VerticalSamplingFactor == 1 &&
535
541
this . Components [ 2 ] . HorizontalSamplingFactor == 1 && this . Components [ 1 ] . HorizontalSamplingFactor == 1 && this . Components [ 0 ] . HorizontalSamplingFactor == 1 )
Original file line number Diff line number Diff line change @@ -216,6 +216,19 @@ public void Issue2057_DecodeWorks<TPixel>(TestImageProvider<TPixel> provider)
216
216
}
217
217
}
218
218
219
+ // https://github.com/SixLabors/ImageSharp/issues/2133
220
+ [ Theory ]
221
+ [ WithFile ( TestImages . Jpeg . Issues . Issue2133DeduceColorSpace , PixelTypes . Rgba32 ) ]
222
+ public void Issue2133_DeduceColorSpace < TPixel > ( TestImageProvider < TPixel > provider )
223
+ where TPixel : unmanaged, IPixel < TPixel >
224
+ {
225
+ using ( Image < TPixel > image = provider . GetImage ( JpegDecoder ) )
226
+ {
227
+ image . DebugSave ( provider ) ;
228
+ image . CompareToOriginal ( provider ) ;
229
+ }
230
+ }
231
+
219
232
// DEBUG ONLY!
220
233
// The PDF.js output should be saved by "tests\ImageSharp.Tests\Formats\Jpg\pdfjs\jpeg-converter.htm"
221
234
// into "\tests\Images\ActualOutput\JpegDecoderTests\"
Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ public static class Issues
265
265
public const string Issue2057App1Parsing = "Jpg/issues/Issue2057-App1Parsing.jpg" ;
266
266
public const string ExifNullArrayTag = "Jpg/issues/issue-2056-exif-null-array.jpg" ;
267
267
public const string ValidExifArgumentNullExceptionOnEncode = "Jpg/issues/Issue2087-exif-null-reference-on-encode.jpg" ;
268
+ public const string Issue2133DeduceColorSpace = "Jpg/issues/Issue2133.jpg" ;
268
269
269
270
public static class Fuzz
270
271
{
You can’t perform that action at this time.
0 commit comments