Skip to content

Commit df7fa40

Browse files
author
Johannes Bildstein
committed
move ICC validity check to InitDerivedMetaDataProperties
1 parent 70a52db commit df7fa40

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,6 @@ public void ParseStream(Stream stream, bool metadataOnly = false)
413413
}
414414

415415
this.InitDerivedMetaDataProperties();
416-
417-
if (this.MetaData.IccProfile?.CheckIsValid() == false)
418-
{
419-
this.MetaData.IccProfile = null;
420-
}
421416
}
422417

423418
/// <summary>
@@ -455,6 +450,11 @@ private void InitDerivedMetaDataProperties()
455450
this.MetaData.VerticalResolution = verticalValue;
456451
}
457452
}
453+
454+
if (this.MetaData.IccProfile?.CheckIsValid() == false)
455+
{
456+
this.MetaData.IccProfile = null;
457+
}
458458
}
459459

460460
/// <summary>

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public Image<TPixel> Decode<TPixel>(Stream stream)
196196
where TPixel : struct, IPixel<TPixel>
197197
{
198198
this.ParseStream(stream);
199-
this.AssignResolution();
199+
this.InitDerivedMetaDataProperties();
200200
return this.PostProcessIntoImage<TPixel>();
201201
}
202202

@@ -207,7 +207,7 @@ public Image<TPixel> Decode<TPixel>(Stream stream)
207207
public IImageInfo Identify(Stream stream)
208208
{
209209
this.ParseStream(stream, true);
210-
this.AssignResolution();
210+
this.InitDerivedMetaDataProperties();
211211
return new ImageInfo(new PixelTypeInfo(this.BitsPerPixel), this.ImageWidth, this.ImageHeight, this.MetaData);
212212
}
213213

@@ -266,7 +266,7 @@ public void ParseStream(Stream stream, bool metadataOnly = false)
266266
{
267267
// It's highly unlikely that APPn related data will be found after the SOS marker
268268
// We should have gathered everything we need by now.
269-
break;
269+
return;
270270
}
271271

272272
case JpegConstants.Markers.DHT:
@@ -345,11 +345,6 @@ public void ParseStream(Stream stream, bool metadataOnly = false)
345345
// Read on.
346346
fileMarker = FindNextFileMarker(this.markerBuffer, this.InputStream);
347347
}
348-
349-
if (this.MetaData.IccProfile?.CheckIsValid() == false)
350-
{
351-
this.MetaData.IccProfile = null;
352-
}
353348
}
354349

355350
/// <inheritdoc/>
@@ -400,9 +395,9 @@ private JpegColorSpace DeduceJpegColorSpace()
400395
}
401396

402397
/// <summary>
403-
/// Assigns the horizontal and vertical resolution to the image if it has a JFIF header or EXIF metadata.
398+
/// Assigns derived metadata properties to <see cref="MetaData"/>, eg. horizontal and vertical resolution if it has a JFIF header.
404399
/// </summary>
405-
private void AssignResolution()
400+
private void InitDerivedMetaDataProperties()
406401
{
407402
if (this.jFif.XDensity > 0 && this.jFif.YDensity > 0)
408403
{
@@ -425,6 +420,11 @@ private void AssignResolution()
425420
this.MetaData.VerticalResolution = verticalValue;
426421
}
427422
}
423+
424+
if (this.MetaData.IccProfile?.CheckIsValid() == false)
425+
{
426+
this.MetaData.IccProfile = null;
427+
}
428428
}
429429

430430
/// <summary>

0 commit comments

Comments
 (0)