ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

Progressive jpeg with missing EOI marker throws EOFException (Part 2)

Open justintubbs opened this issue 8 years ago • 10 comments

Similar to this previously closed Issue, I have JPG files from iPhone 3 and other devices that still gets this error:

Example JPG images: image1.jpg image2.jpg

Using ImageSharp nightly dev NuGet (also tried stable/release which has same issue)

<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-dev000642" />

Stack Trace:

SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder.EOFException
  HResult=0x80131500
  Message=Reached end of stream before proceeding EOI marker!
  Source=SixLabors.ImageSharp
  StackTrace:
   at SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder.DecoderThrowHelper.ThrowExceptionForErrorCode(OrigDecoderErrorCode errorCode)
   at SixLabors.ImageSharp.Formats.Jpeg.GolangPort.OrigJpegDecoderCore.ParseStream(Stream stream, Boolean metadataOnly)
   at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Decode[TPixel](Configuration configuration, Stream stream)
   at AdvisorSolutions360.WebApi.Controllers.AdvisorsController.UpdateReportBranding(Guid advisorId, String PrimaryColor, String SecondaryColor, IFormFile file) in C:\Users\jtubbs\Desktop\code\AdvisorSolutions360.WebApi\Controllers\AdvisorsController.cs:line 160
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()

Code I'm using:

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;

public IActionResult UpdateReportBranding([FromForm] IFormFile file)
{
   var ms = new MemoryStream();
   file.OpenReadStream().CopyTo(ms);
   IImageDecoder decoder = new SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder();
   var image = Image.Load(ms, decoder); << EXCEPTION

Workaround As mentioned in Issue #18, I can add a try/catch to "fix" this issue

justintubbs avatar Jan 19 '18 20:01 justintubbs

Hi @justintubbs

Thanks for the info, Can you fix those image links please so I can have a look at them. I'm getting a 403 error.

@antonfirsov Looking at the codebase it looks like we are not calling the EnsureNoEOF at any point but rather EnsureNoError without checking to see wther we have image data first.

JimBobSquarePants avatar Jan 19 '18 23:01 JimBobSquarePants

Is anyone else having issues getting to these photos? I can view them in multiple browsers, even in Incognito/Private browsing mode

justintubbs avatar Jan 21 '18 19:01 justintubbs

image

justintubbs avatar Jan 21 '18 19:01 justintubbs

image

justintubbs avatar Jan 21 '18 19:01 justintubbs

@justintubbs Those attached images are pngs?

JimBobSquarePants avatar Jan 21 '18 22:01 JimBobSquarePants

@justintubbs Can you provide the appropriate jpegs please? Otherwise I'm going to have to close this issue.

Thanks!

JimBobSquarePants avatar Feb 07 '18 06:02 JimBobSquarePants

Sorry for my 2c, I was looking for issues on github similar to what we had with JPEG and stumbled on this thread.

Thanks for the great library!

Looks like links from the opening comment are working and there are JPEG images there. Not sure if these are the images that caused issue.

alexsorokoletov avatar Feb 09 '18 01:02 alexsorokoletov

@alexsorokoletov You can see them? Great!

Can you do me a huge favor and add them in a zip file to this thread? We're all getting 403 Forbidden statuses when trying to view the images.

JimBobSquarePants avatar Feb 09 '18 01:02 JimBobSquarePants

Here you go :) Image1and2.zip

alexsorokoletov avatar Feb 09 '18 02:02 alexsorokoletov

Thanks for that! I can confirm that both images work perfectly with the latest nightlies.

Closing this issue.

JimBobSquarePants avatar Feb 09 '18 03:02 JimBobSquarePants