Page 1 of 1

Skip empty frames when comparing layers

Posted: 2015-03-20T13:51:20-07:00
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;
]]]

Re: Skip empty frames when comparing layers

Posted: 2015-03-20T18:33:32-07:00
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.