Page 1 of 1

"clone" discards all but one frame of animated GIF

Posted: 2014-04-24T12:08:57-07:00
by boutell
We use command lines like this to resize an image to various sizes in a single command so we don't decode the original image over and over. It's quite fast:

convert input.jpg -resize '1600x1280>' '(' +clone -resize '1140x1440>' -write big.jpg '+delete' ')' '(' +clone -resize '760x760>' -write small.jpg '+delete' ')' null:

Here I'm first scaling to a maximum size as a more efficient starting point for the other resizes than the original image, which could be enormous.

Then I'm cloning, resizing, and writing two different sizes.

Then I discard the 1600x1280 version which I don't actually need to keep (thus null:).

This works fine with a JPEG (as shown here), PNG, or single-frame GIF file.

However with an animated GIF the animation is lost in all of the scaled versions.

It appears that +clone discards information about all but the first (?) frame of the GIF.

Is this a bug or am I misunderstanding the intended feature set of +clone?

I'm using 6.8.7-7.

Thanks!

Re: "clone" discards all but one frame of animated GIF

Posted: 2014-04-24T12:48:19-07:00
by snibgo
See http://www.imagemagick.org/script/comma ... .php#clone

"+clone" only copies one image. As the documentation says, "A value of '0−−1 will effectively clone all the images."

Re: "clone" discards all but one frame of animated GIF

Posted: 2014-04-24T19:24:24-07:00
by boutell
AHA! If I do this, is the interframe delay timing information preserved?

Thanks!

Re: "clone" discards all but one frame of animated GIF

Posted: 2014-04-25T05:01:43-07:00
by snibgo
If the outputs were gifs, I think your command would preserve delays, but I'm not sure. I'm not an expert on animated gifs. You might read the animation pages linked to from http://www.imagemagick.org/Usage/ .

But your outputs are jpgs. Each output will create one jpg per gif frame, and there will be no interframe delay timing information.

Re: "clone" discards all but one frame of animated GIF

Posted: 2014-04-25T07:53:07-07:00
by boutell
snibgo, the command line I gave was a JPEG, yes, but in my explanation I clarified that if you try the same trick with a GIF you run into the issue I mentioned if it's animated. Just clarifying - I appreciate the advice on the proper use of clone. I'll try it out and report back.