我在打开 jpg 文件时遇到问题。这是我开始的代码:
var image = await Image.LoadAsync("sample.jpg")
这产生了异常:
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
为了确定文件未被识别为 jpeg 的原因,我使用了以下代码:
using (var stream = File.OpenRead("sample.jpg"))
{
var jpegDecoder = new JpegDecoder();
jpegDecoder.Decode(Configuration.Default, stream);
}
这给了我以下异常:
An unhandled exception of type 'SixLabors.ImageSharp.InvalidImageContentException' occurred in SixLabors.ImageSharp.dll
Missing SOI marker.
我倾向于认为所涉及的图像有问题,但我可以在 Windows 照片查看器和 Google Chrome 中查看它。如何确定文件有什么问题?
编辑:
感谢@user9938,我能够确定这是一个 RIFF 或 WEBPV8 文件:
是否有 ImageSharp 的 riff 插件?
最佳答案
关于c# - 获取 '' 缺少 SOI 标记。来自 JpegDecoderr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70792715/