dlemstra / Magick.NET

The .NET library for ImageMagick
Apache License 2.0
3.48k stars 415 forks source link

Cannot load animated avif images. #1526

Open GoldenGuy opened 10 months ago

GoldenGuy commented 10 months ago

Magick.NET version

13.5.0

Environment (Operating system, version and so on)

Win10 pro 22H2 x64

Description

i am able to load static avif/heic imageges, but any animated image i tried i got this exception:

Unhandled exception. ImageMagick.MagickMissingDelegateErrorException: no decode delegate for this image format `' @ error/blob.c/CustomStreamToImage/810
   at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result) in /_/src/Magick.NET/Native/NativeInstance.cs:line 57
   at ImageMagick.MagickImage.NativeMagickImage.ReadStream(IMagickSettings`1 settings, ReadWriteStreamDelegate reader, SeekStreamDelegate seeker, TellStreamDelegate teller) in /_/src/Magick.NET/Native/MagickImage.cs:line 7037
   at ImageMagick.MagickImage.Read(Stream stream, IMagickReadSettings`1 readSettings, Boolean ping) in /_/src/Magick.NET/MagickImage.cs:line 7635
   at ImageMagick.MagickImage.Ping(Stream stream, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImage.cs:line 4549
   at ImageMagick.MagickImageInfo.Read(Stream stream, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImageInfo.cs:line 406
   at ImageMagick.MagickImageInfo..ctor(Stream stream, IMagickReadSettings`1 readSettings) in /_/src/Magick.NET/MagickImageInfo.cs:line 133
   at ImageMagick.MagickImageInfo..ctor(Stream stream) in /_/src/Magick.NET/MagickImageInfo.cs:line 121
   at TwitchChat.ImageDownloader.DownloadImage(String name, String url) in D:\VS\TwitchChat\ImageDownloader.cs:line 42
   at TwitchChat.Program.Main(String[] args) in D:\VS\TwitchChat\Program.cs:line 67
   at TwitchChat.Program.<Main>(String[] args)

Steps to Reproduce

here is my code

byte[] imageData = await httpClient.GetByteArrayAsync(url);
using (MemoryStream inputStream = new MemoryStream(imageData))
{
    var info = new ImageMagick.MagickImageInfo(inputStream);
    Console.WriteLine($"format: {info.Format}");
}

test images i used are these: https://github.com/colinbendell/webperf/tree/master/animated-gif-decode and these: https://github.com/link-u/avif-sample-images

dlemstra commented 10 months ago

It looks like animated avif images are not yet supported by the library that is being used in this project: https://github.com/strukturag/libheif/issues/377.

GoldenGuy commented 10 months ago

Maybe libavif could be used for this? Doesnt seem like there is any progress in libheif to add support for animated avis...

dlemstra commented 10 months ago

That library is being used by libheif to read avif files.