'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 1:[1]

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

Solution 2:[2]

if Image.Load(imageStream) called with a fileStream but Position is not set to zero you can also get decoder not found kind of errors...

stream.Position = 0;

https://github.com/SixLabors/ImageSharp/issues/164#issuecomment-291784371

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RQDQ
Solution 2 Serdar