From 13f244af4044bf250307889bd6cd974ee665d01a Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 24 Sep 2019 19:47:20 +0200 Subject: [PATCH] Make ImageMagick multi-image size calculations work for .ico files * src/image.c (imagemagick_load_image): Compute image sizes correctly in multi-image .ico files and the like (bug#18333). --- src/image.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/image.c b/src/image.c index 06a8154842c..7cf1bc4c362 100644 --- a/src/image.c +++ b/src/image.c @@ -8896,12 +8896,28 @@ imagemagick_load_image (struct frame *f, struct image *img, "super-wand". */ if (MagickGetNumberImages (image_wand) > 1) { - MagickWand *super_wand = image_wand; - image_wand = imagemagick_compute_animated_image (super_wand, ino); - if (! image_wand) - image_wand = super_wand; + /* This is an animated image (it has a delay), so compute the + composite image etc. */ + if (MagickGetImageDelay (image_wand) > 0) + { + MagickWand *super_wand = image_wand; + image_wand = imagemagick_compute_animated_image (super_wand, ino); + if (! image_wand) + image_wand = super_wand; + else + DestroyMagickWand (super_wand); + } else - DestroyMagickWand (super_wand); + /* This is not an animated image: It's just a multi-image file + (like an .ico file). Just return the correct + sub-image. */ + { + MagickWand *super_wand = image_wand; + + MagickSetIteratorIndex (super_wand, ino); + image_wand = MagickGetImage (super_wand); + DestroyMagickWand (super_wand); + } } /* Retrieve the frame's background color, for use later. */ -- 2.39.2