Subject: bug#6981: create-animated-image doesn't animate

From: Juri Linkov <[email-masked]>
Date: Mon, 06 Sep 2010 22:32:43 +0100

> Note the following limitation mentioned in the comment in image.c:
>
>   /* Clear the part of the screen image that are not covered by
>      the image from the GIF file.  Full animated GIF support
>      requires more than can be done here (see the gif89 spec,
>      disposal methods).  Let's simply assume that the part
>      not covered by a sub-image is in the frame's background color.  */

So we have two separate problems.  The first problem is this limitation.
In Gimp I see animated image frames described as "combine".  It seems
this corresponds to the disposal method 1 ("do not dispose, the graphic
is to be left in place") in http://www.w3.org/Graphics/GIF/spec-gif89a.txt
I rememeber there was a function in imagemagick that can do this.

> (setq img (create-animated-image "~/oii.gif"))
> (insert-image img)
> (image-animate-start img)
>
> The last line seems to be neccesary, even though create-animated-image
> starts the animation itself. Other changes to the buffer contents seem
> to stop the animation so that line needs to be evaluated again.

Thanks for the hint.  Since animation works (with the limitation above)
when inserted by `insert-image', but doesn't work with `image-mode',
the bug is in `image-mode'.  And indeed, removing `append' with
`image-transform-properties' in `image-toggle-display-image' like

@@ -494,10 +494,7 @@ (defun image-toggle-display-image ()
 			    (buffer-substring-no-properties (point-min) (point-max)))
 			 filename))
 	 (type (image-type file-or-data nil data-p))
-         (image0 (create-animated-image file-or-data type data-p))
-	 (image (append image0
-                        (image-transform-properties image0)
-                        ))
+         (image (create-animated-image file-or-data type data-p))
 	 (props
 	  `(display ,image
 		    intangible ,image

fixes this bug and restores animation.  This means that the Lisp object of
the created image should not be changed.

Joakim, this suggests that the function `image-transform-properties'
you recently added should nconc display properties to the end
of the image spec.