Error insufficient image data in webp file
Magick.NET version
magick.net-q16-x86.9.0.0.nupkg, magick.net-q16-x86.12.2.1.nupkg, magick.net-q8-x86.13.5.0.nupkg, magick.net-q16-x86.13.5.0.nupkg
Environment (Operating system, version and so on)
Windows 10, 32bit
Description
I try to use Magick.Net with this code (from stackoverflow)
using (var magickImages = new MagickImageCollection(filePath)) // Exception in this line { if (magickImages.Count > 1) { string newFilePath = FileHelpers.GenerateNewFilePath(Path.ChangeExtension(filePath, ".gif")); using (FileStream fs = new FileStream(newFilePath, FileMode.Create)) { magickImages.Write(fs, MagickFormat.Gif); } } else { string newFilePath = FileHelpers.GenerateNewFilePath(Path.ChangeExtension(filePath, ".png")); using (FileStream fs = new FileStream(newFilePath, FileMode.Create)) { magickImages.Write(fs, MagickFormat.Png); } } }
and got Exception when opening file for both sample files with message
insufficient image data in file sher3.webp' @ error/webp.c/ReadWEBPImage/563 insufficient image data in file sher3l.webp' @ error/webp.c/ReadWEBPImage/563
images.zip
Steps to Reproduce
To reproduce use above code with attached images.zip.
I try following Magick.Net nuget packages (with correspondent dependencies):
magick.net-q16-x86.6.8.9.501.nupkg magick.net-q16-x86.9.0.0.nupkg magick.net-q16-x86.12.2.1.nupkg magick.net-q8-x86.13.5.0.nupkg magick.net-q16-x86.13.5.0.nupkg
and only v.6.8.9.501 open both files successfully, all other - fail with above messages.
I try to use ImageMagick command tool (ImageMagick-7.1.1-27-Q16-x86-dll.exe) and file 'sher3.webp' success and for 'sher3l.webp' got this:
magick convert sher3l.webp sher3l.png
convert: insufficient image data in file sher3l.webp' @ error/webp.c/ReadWEBPImage/580. convert: no images defined sher3l.png' @ error/convert.c/ConvertImageCommand/3362.
Both sample files in XnView or other free viewer/converter opens fine and converts fine.
I find in issue list that similar exception message exists for jpg and png files (I think it is already fixed).
Your webp file is invalid and checks have been added that will cause this error message. For your sher3.webp file I already made a patch earlier that would make it possible to read that incorrect file. And I just pushed a patch to make it possible to also read sher3l.webp. This will be resolved in the next release.