"clone" discards all but one frame of animated GIF

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
boutell
Posts: 4
Joined: 2013-11-29T10:46:21-07:00
Authentication code: 6789

"clone" discards all but one frame of animated GIF

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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."
snibgo's IM pages: im.snibgo.com
boutell
Posts: 4
Joined: 2013-11-29T10:46:21-07:00
Authentication code: 6789

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

Post by boutell »

AHA! If I do this, is the interframe delay timing information preserved?

Thanks!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
boutell
Posts: 4
Joined: 2013-11-29T10:46:21-07:00
Authentication code: 6789

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

Post 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.
Post Reply