From 73d35b779c9e113c66c17e359c9e020e4b3f4141 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Sun, 11 Jul 2021 14:35:14 +0300 Subject: [PATCH] Fixed no color deduction for metadata only pass --- src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 08e6ae021f..a45f51db05 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -875,6 +875,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg this.ImageSizeInPixels = new Size(this.Frame.PixelWidth, this.Frame.PixelHeight); this.ComponentCount = this.Frame.ComponentCount; + this.ColorSpace = this.DeduceJpegColorSpace(); + this.Metadata.GetJpegMetadata().ColorType = this.ColorSpace == JpegColorSpace.Grayscale ? JpegColorType.Luminance : JpegColorType.YCbCr; + if (!metadataOnly) { remaining -= length; @@ -891,7 +894,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg this.Frame.ComponentIds = new byte[this.ComponentCount]; this.Frame.ComponentOrder = new byte[this.ComponentCount]; this.Frame.Components = new JpegComponent[this.ComponentCount]; - this.ColorSpace = this.DeduceJpegColorSpace(); int maxH = 0; int maxV = 0; @@ -922,8 +924,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg this.Frame.MaxHorizontalFactor = maxH; this.Frame.MaxVerticalFactor = maxV; - this.ColorSpace = this.DeduceJpegColorSpace(); - this.Metadata.GetJpegMetadata().ColorType = this.ColorSpace == JpegColorSpace.Grayscale ? JpegColorType.Luminance : JpegColorType.YCbCr; this.ImageSizeInMCU = new Size(this.Frame.McusPerLine, this.Frame.McusPerColumn); this.Frame.InitComponents();