From df7fa403bbb00e3fc03cd7c27a5282857d686fef Mon Sep 17 00:00:00 2001 From: Johannes Bildstein Date: Wed, 23 May 2018 13:22:28 +0200 Subject: [PATCH] move ICC validity check to InitDerivedMetaDataProperties --- .../Jpeg/GolangPort/GolangJpegDecoderCore.cs | 10 +++++----- .../Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs index 0ee704c9a..86f97d224 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs @@ -413,11 +413,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort } this.InitDerivedMetaDataProperties(); - - if (this.MetaData.IccProfile?.CheckIsValid() == false) - { - this.MetaData.IccProfile = null; - } } /// @@ -455,6 +450,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort this.MetaData.VerticalResolution = verticalValue; } } + + if (this.MetaData.IccProfile?.CheckIsValid() == false) + { + this.MetaData.IccProfile = null; + } } /// diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs index 24968fd35..752e72dd2 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs @@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort where TPixel : struct, IPixel { this.ParseStream(stream); - this.AssignResolution(); + this.InitDerivedMetaDataProperties(); return this.PostProcessIntoImage(); } @@ -207,7 +207,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort public IImageInfo Identify(Stream stream) { this.ParseStream(stream, true); - this.AssignResolution(); + this.InitDerivedMetaDataProperties(); return new ImageInfo(new PixelTypeInfo(this.BitsPerPixel), this.ImageWidth, this.ImageHeight, this.MetaData); } @@ -266,7 +266,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort { // It's highly unlikely that APPn related data will be found after the SOS marker // We should have gathered everything we need by now. - break; + return; } case JpegConstants.Markers.DHT: @@ -345,11 +345,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort // Read on. fileMarker = FindNextFileMarker(this.markerBuffer, this.InputStream); } - - if (this.MetaData.IccProfile?.CheckIsValid() == false) - { - this.MetaData.IccProfile = null; - } } /// @@ -400,9 +395,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort } /// - /// Assigns the horizontal and vertical resolution to the image if it has a JFIF header or EXIF metadata. + /// Assigns derived metadata properties to , eg. horizontal and vertical resolution if it has a JFIF header. /// - private void AssignResolution() + private void InitDerivedMetaDataProperties() { if (this.jFif.XDensity > 0 && this.jFif.YDensity > 0) { @@ -425,6 +420,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort this.MetaData.VerticalResolution = verticalValue; } } + + if (this.MetaData.IccProfile?.CheckIsValid() == false) + { + this.MetaData.IccProfile = null; + } } ///