From a6df4699979988bed0098c128490ddf24c4a91f7 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Tue, 10 Jun 2014 15:31:03 +0100 Subject: [PATCH] Coalesce animated gifs before resizing them. Fixes #264 In an animated gif, each frame is only the size it needs to be to cover the changed part of the image. This is often much lower than the actual image size and the Wand image backend was using this incorrect size in its resizing calculations, causing all animated gifs to be resized incorrectly or not at all. This commit calls ImageMagicks "MagickCoalesceImages" on the wand image. This resizes every frame to the full size of the image so the resizing calculations will work properly. --- wagtail/wagtailimages/backends/wand.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wagtail/wagtailimages/backends/wand.py b/wagtail/wagtailimages/backends/wand.py index d1a877436..91f2d255a 100644 --- a/wagtail/wagtailimages/backends/wand.py +++ b/wagtail/wagtailimages/backends/wand.py @@ -2,6 +2,7 @@ from __future__ import absolute_import from .base import BaseImageBackend from wand.image import Image +from wand.api import library class WandBackend(BaseImageBackend): @@ -10,6 +11,7 @@ class WandBackend(BaseImageBackend): def open_image(self, input_file): image = Image(file=input_file) + image.wand = library.MagickCoalesceImages(image.wand) return image def save_image(self, image, output, format):