dlemstra / Magick.NET

The .NET library for ImageMagick

Repository from Github https://github.comdlemstra/Magick.NETRepository from Github https://github.comdlemstra/Magick.NET

read a avif error ,use MagickImage.Read(rawbytes);

Charltsing opened this issue · comments

Magick.NET version

13.10.0

Environment (Operating system, version and so on)

Windows10, net framework 4.7.2

Description

read a avif as bytes data report error, use MagickImage.Read(rawbytes);
read it as file work fine

avif-error.zip

ImageMagick.MagickMissingDelegateErrorException
HResult=0x80131500
Message=no decode delegate for this image format ' @ error/blob.c/BlobToImage/481 Source=Magick.NET-Q16-OpenMP-x64 StackTrace: 在 ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result) 在 ImageMagick.MagickImage.NativeMagickImage.ReadBlob(IMagickSettings1 settings, Byte[] data, UIntPtr offset, UIntPtr length)
在 ImageMagick.MagickImage.Read(Byte[] data, UIntPtr offset, UIntPtr length, IMagickReadSettings1 readSettings, Boolean ping, String fileName) 在 ImageMagick.MagickImage.Read(Byte[] data, IMagickReadSettings1 readSettings)
在 ImageMagick.MagickImage.Read(Byte[] data)

Steps to Reproduce

..

That is because ImageMagick cannot detect the format from the header and uses the file extension to guess the format. You will need to specify the format.

ImageMagick can recognize the other sample.avif and sample2.avif, but cannot recognize sample3.avif. Is it possible to enhance the read function?

avifs.zip

1
2
3

I will need to investigate if that is possible. I already made other enhancements earlier.

And it turned out that it was easy to add support for this. In the next release you can read this file from a byte array:

sample HEIC 123x456 123x456+0+0 8-bit sRGB 13159B 0.001u 0:00.001
sample2 AVIF 800x533 800x533+0+0 8-bit sRGB 113604B 0.001u 0:00.000
sample3 AVIF 1280x720 1280x720+0+0 8-bit sRGB 409566B 0.001u 0:00.000