Skip to content

Commit dd6b4c1

Browse files
committed
Deduce color space as YCbCr if component id's are 1, 2, 3
1 parent 0eb411c commit dd6b4c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ private JpegColorSpace DeduceJpegColorSpace(byte componentCount)
556556
return JpegColorSpace.RGB;
557557
}
558558

559+
// If these values are 1-3 for a 3-channel image, then the image is assumed to be YCbCr.
560+
if (this.Components[2].Id == 3 && this.Components[1].Id == 2 && this.Components[0].Id == 1)
561+
{
562+
return JpegColorSpace.YCbCr;
563+
}
564+
559565
// 3-channel non-subsampled images are assumed to be RGB.
560566
if (this.Components[2].VerticalSamplingFactor == 1 && this.Components[1].VerticalSamplingFactor == 1 && this.Components[0].VerticalSamplingFactor == 1 &&
561567
this.Components[2].HorizontalSamplingFactor == 1 && this.Components[1].HorizontalSamplingFactor == 1 && this.Components[0].HorizontalSamplingFactor == 1)

0 commit comments

Comments
 (0)