From: Lars Ingebrigtsen Date: Tue, 24 Sep 2019 17:47:20 +0000 (+0200) Subject: Make ImageMagick multi-image size calculations work for .ico files X-Git-Tag: emacs-27.0.90~1439 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=13f244af4044bf250307889bd6cd974ee665d01a;p=emacs.git 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). --- 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. */