Skip empty frames when comparing layers

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
hwright
Posts: 6
Joined: 2015-02-20T10:24:16-07:00
Authentication code: 6789

Skip empty frames when comparing layers

Post by hwright »

When two consecutive frames are identical, the second one will be turned into an empty frame. In this case, the empty frame should be skipped when comparing layers. This patch should fix the problem.

Code: Select all

[[[
Index: magick/layer.c
===================================================================
--- magick/layer.c	(revision 18240)
+++ magick/layer.c	(working copy)
@@ -854,6 +854,14 @@
   next=GetNextImageInList(next);
   for ( ; next != (const Image *) NULL; next=GetNextImageInList(next))
   {
+    if (bounds[i].x == -1 && bounds[i].y == -1 &&
+        bounds[i].width == 1 && bounds[i].height == 1) {
+      // An empty frame is returned from CompareImageBounds(), which
+      // means the current frame is identical to the previous frame.
+      i++;
+      continue;
+    }
+
     image_a=CloneImage(next,0,0,MagickTrue,exception);
     if (image_a == (Image *) NULL)
       break;
]]]
-Hyrum
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Skip empty frames when comparing layers

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.9.1-1 Beta, available by sometime tomorrow. Thanks.
Post Reply