Tile animated gifs

9

2

Is there some way to use imagemagic / montage to tile looped animated gifs (intermixed with nonanimated ones)?

That is, I want to concatenate the animations in space, not in time. I realize that the number of frames and their duration in the animation might make it impossible to neatly combine two animations. But I'm fine with the program making approximations and guesses, and extending/repeating frames, as long as all the frames are there in some fashion.

I've tried

convert *.gif -append output.gif

and

montage *.gif -mode concatenate -tile x1 output.gif

but these both treat the animated gifs as multiple individual non-animated ones.

I suppose I could probably write a script to break the animated ones apart by frames, repeat / extend shorter loops as necessary to match the longest loop, repeat the nonanimated gifs for as many frames are in the longest animated one, stitch together the corresponding frames into single large frames with -append, and then combine those large frames into one large gif. But I don't want to reinvent the wheel if this is already possible by some simple command.

I'm of course open to other free options besides imagemagick.

tsbertalan

Posted 2013-04-07T01:22:24.150

Reputation: 325

1@tsbertalan Did you eventually figure this out? – Seb Barre – 2017-11-23T18:56:38.100

http://how-to.ytmnd.com/ – Ƭᴇcʜιᴇ007 – 2013-04-07T03:00:39.780

2I'm going to take that as it probably wasn't intended; as a serious comment. Yes, I want to tile GIFs. But permanently, not in HTML. Thank you for the link. I will save that particular GIF for later use. – tsbertalan – 2013-04-08T03:12:51.270

Answers

1

It sounds like you want to match up several animations through time, but that's going to take a program to read each frame and its delay, then output that frame at some periodic frequency until the delay is met. eg: 1 frame, delay of 1 second, and your 'frequency' is 100ms, so you'd want 10 frames at 100ms written out? And then converted to a linear montage?

That would need a program or hefty script to perform that kind of processing, and you'd have to define your 'frequency' (100ms here).

But this works nicely: (gifsicle is a package, montage is part of the imagemagick package)

gifsicle --unoptimize cool_animation.gif | \
  montage -tile x1 - linear_frames.png

(line broken for readability)

First line breaks apart the incoming gif into individual frames (to stdout), but with the layers filled out. initially, without the --unoptimize option, it would give the first frame, but the subsequent frames only contained what changed each time. Made for weird montages!

Second line builds the linear output, taking each frame image (from stdin) and arranging them in the order you specify. 'x1' to arrange them along a horizontal line.

You could replace the single filename (cool_animation.gif) with several, or even a wildcard *.gif.

I not sure this is what you're looking for though.

lornix

Posted 2013-04-07T01:22:24.150

Reputation: 9 633

When modified to gifsicle --colors=255 DATA.gif | gifsicle --unoptimize | montage -tile x1 - linear_frames.png for Ƭᴇcʜιᴇ007's test image, this gives me https://imgur.com/a/Likr9; not exactly what I'm looking for. I can't remember the original purpose; I suppose I probably just wrote a script to break it all out explicitly.

– tsbertalan – 2017-11-24T16:09:03.497