Browse Source

move ICC validity check to InitDerivedMetaDataProperties

pull/588/head
Johannes Bildstein 8 years ago
parent
commit
df7fa403bb
  1. 10
      src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs
  2. 20
      src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs

10
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;
}
}
/// <summary>
@ -455,6 +450,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
this.MetaData.VerticalResolution = verticalValue;
}
}
if (this.MetaData.IccProfile?.CheckIsValid() == false)
{
this.MetaData.IccProfile = null;
}
}
/// <summary>

20
src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs

@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
where TPixel : struct, IPixel<TPixel>
{
this.ParseStream(stream);
this.AssignResolution();
this.InitDerivedMetaDataProperties();
return this.PostProcessIntoImage<TPixel>();
}
@ -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;
}
}
/// <inheritdoc/>
@ -400,9 +395,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
}
/// <summary>
/// Assigns the horizontal and vertical resolution to the image if it has a JFIF header or EXIF metadata.
/// Assigns derived metadata properties to <see cref="MetaData"/>, eg. horizontal and vertical resolution if it has a JFIF header.
/// </summary>
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;
}
}
/// <summary>

Loading…
Cancel
Save