Search code examples
c#jpegimagesharp

Getting ''Missing SOI marker.' from JpegDecoderr


I'm running into issues opening a jpg file. Here is the code I started with:

var image = await Image.LoadAsync("sample.jpg")

This produced the exception:

An exception of type 'SixLabors.ImageSharp.UnknownImageFormatException' occurred in System.Private.CoreLib.dll but was not handled in user code
Image cannot be loaded. Available decoders:
 - PNG : PngDecoder
 - GIF : GifDecoder
 - BMP : BmpDecoder
 - TGA : TgaDecoder
 - JPEG : JpegDecoder

To determine why the file wasn't recognized as jpeg, I used the following code:

using (var stream = File.OpenRead("sample.jpg"))
{
   var jpegDecoder = new JpegDecoder();

   jpegDecoder.Decode(Configuration.Default, stream);
}

That gave me the following exception:

An unhandled exception of type 'SixLabors.ImageSharp.InvalidImageContentException' occurred in SixLabors.ImageSharp.dll
Missing SOI marker.

I'm inclined to believe that the image involved has an issue, but I'm able to view it in windows photo viewer and in Google Chrome. How do I determine what is wrong with the file?

Edit:

Thanks to @user9938, I was able to determine that this is a RIFF or WEBPV8 file:

Hex viewer

Is there a riff plugin for ImageSharp by any chance?


Solution

  • It looks like the ImageSharp folks have been toiling away at WebP support.

    This issue does a great job of describing where the progress is at:

    https://github.com/SixLabors/ImageSharp/issues/121

    enter image description here