Browse Source

Skip SOS contents when parsing metadata only

pull/549/head
James Jackson-South 8 years ago
parent
commit
934e2bce34
  1. 15
      src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs
  2. 6
      src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs

15
src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs

@ -361,15 +361,18 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
break;
case OrigJpegConstants.Markers.SOS:
if (!metadataOnly)
if (metadataOnly)
{
this.ProcessStartOfScanMarker(remaining);
this.InputProcessor.Skip(remaining);
}
if (this.InputProcessor.ReachedEOF)
else
{
// If unexpected EOF reached. We can stop processing bytes as we now have the image data.
processBytes = false;
this.ProcessStartOfScanMarker(remaining);
if (this.InputProcessor.ReachedEOF)
{
// If unexpected EOF reached. We can stop processing bytes as we now have the image data.
processBytes = false;
}
}
break;

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

@ -246,7 +246,11 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort
break;
case PdfJsJpegConstants.Markers.SOS:
if (!metadataOnly)
if (metadataOnly)
{
this.InputStream.Skip(remaining);
}
else
{
this.ProcessStartOfScanMarker();
}

Loading…
Cancel
Save