Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

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

Open Charltsing opened this issue 1 year ago • 4 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

..

Charltsing avatar Aug 06 '24 02:08 Charltsing

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.

dlemstra avatar Aug 06 '24 06:08 dlemstra

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

Charltsing avatar Aug 06 '24 08:08 Charltsing

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

dlemstra avatar Aug 06 '24 08:08 dlemstra

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

dlemstra avatar Aug 07 '24 04:08 dlemstra