Page 1 of 1

Create an animated "contact sheet" of gifs

Posted: 2019-10-13T01:11:35-07:00
by trig.vee
Using montage and append seem intended for stills and will unpack animated gifs into individual frames. I would like to combine many gifs into a "contact sheet" of animations. Is this possible without knowing the size of each source gif beforehand? I imagine the source gifs may need to be trimmed or forced into the same speed and duration, which is okay.
Thanks :)

Version: ImageMagick 7.0.8-59 Q16 x86_64 2019-08-05

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T05:36:50-07:00
by snibgo
I'm not sure what you want. Perhaps you have a number of animated GIFs, and you want to create a single GIF that is made from the input GIFs placed side-by-side or below each other, or in a grid.

This is easily done by keeping the GIFs separate, and showing them on an HTML page.

Combining them into a single GIF (which will be limited to 256 colours, and may need re-sizing and re-timing of each input) can be done. See http://www.imagemagick.org/Usage/anim_mods/#append and other sections of that page.

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T07:50:18-07:00
by trig.vee
Thanks, and sorry for my unclear wording. I wanted to combine many GIFs into a single GIF.

It seemed like the 'anim_mod' examples were geared towards when you know the exact size and how many source gifs need to be appended. I was wondering if there was a technique more similar in flexibility to montage, which I can be given any number images, all at different sizes, and it automatically creates a nice "contact sheet". The potential re-sizing and re-timing compromises are not an issue for me.

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T09:00:17-07:00
by snibgo
I think you would need to write a script for that.

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T10:02:02-07:00
by fmw42
Are you asking to take one animated gif and extract all the frames and make a contact sheet of those? Or are you asking to make an animated contact sheet from many animated gifs?

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T10:48:41-07:00
by trig.vee
The latter. I want to make an animated contact sheet from many animated gifs.

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T11:00:24-07:00
by fmw42
trig.vee wrote:
2019-10-13T10:48:41-07:00
The latter. I want to make an animated contact sheet from many animated gifs.
The problem with that is that you need to sync the animations. That generally only works well if you have the same number of frames and the same delays in all the animations. See https://imagemagick.org/Usage/anim_mods/#merging

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T12:10:29-07:00
by trig.vee
I wouldn't mind if the frame counts and delays are adjusted in order to make it work; similar to how montage will resize images to match the largest/smallest image in the grid.

It sounds like there isn't currently a magical way to do this, so I will try this process:

1. Separate each source animation into coalesced static frames.
2. Find the GIF with the most frames (X), and add frames to all other GIFs until they also have X frames.
3. Loop over X frames, grabbing a frame from each source GIF then generating a static contact sheet using the montage command.
4. Finally, take all those static contact sheet images and compile into a single animated contact sheet GIF.

Let me know if a simpler way comes to mind, otherwise thanks for helping me think through it.

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-13T17:01:06-07:00
by fmw42
I can create a montage of animations and it will animate using the latest beta (IM 6.9.10.69 or IM 7.0.8.69). If they have different numbers of frames, an empty spot will appear. So it should be easy for you to create your contact sheet of animations. Just make the tiling correspond to the number of animations you provide and include your new desired delay.

Code: Select all

convert -delay 20 lena.jpg mandril3.jpg zelda1.jpg anim1.gif
convert -delay 20 lena.jpg mandril3.jpg anim2.gif
magick montage -delay 50 anim1.gif anim1.gif anim1.gif anim1.gif -tile 2x2 anim_montage1.gif
magick montage -delay 50 anim1.gif anim1.gif anim1.gif anim2.gif -tile 2x2 anim_montage2.gif
Image

Image

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-14T11:43:44-07:00
by trig.vee
Starting from your example, it seems like ImageMagick jumbles up the frames between different GIFs. In your example, it's hard to tell since the source gifs don't have any linear continuity.

Here's my result using 4 copies the same source gif:

Code: Select all

montage 1a.gif 1b.gif 1c.gif 1d.gif -tile 2x2 montage_same.gif
Source gif: https://tni-art-eater.s3.us-east-2.amaz ... ums/1a.gif
Result:
Image

And 4 completely different source gifs:

Code: Select all

montage 1.gif 2.gif 3.gif 4.gif -tile 2x2 montage_different.gif
Image

Re: Create an animated "contact sheet" of gifs

Posted: 2019-10-14T12:19:43-07:00
by fmw42
You need to add the -delay so we can see better. Perhaps it syncs when a delay is properly set. You need to use the beta version or wait for it to be released in order to use -delay in montage.

Re: Create an animated "contact sheet" of gifs

Posted: 2020-03-15T21:58:00-07:00
by trig.vee
I've finally upgraded to ImageMagick 7.0.10-0. The delay works now, but the gifs are still getting jumbled together. Is this the intended behavior?

Code: Select all

magick montage -delay 50 1.gif 2.gif 3.gif 4.gif -tile 2x2 anim_montage.gif
Image

Re: Create an animated "contact sheet" of gifs

Posted: 2020-03-16T09:39:48-07:00
by fmw42
Your animated gifs need to have the same number of frames and the same delays. Do they?

Re: Create an animated "contact sheet" of gifs

Posted: 2020-03-16T19:30:23-07:00
by trig.vee
Thanks. They do not, which I maybe worded confusingly in my original question. A few posts earlier you seemed to say that white frames would fill in any frame-count disparity, which I liked.

I wouldn't mind if both the frame-rate and frame-count were forced to match as part of the process. I just need to see all the source gifs at once on the same output gif, even if their frame-delays have been altered in the process.

Is there a command that forces all the source GIFs into the same frame-delay and frame-count? If so, I could run that prior to running the montage command.

Re: Create an animated "contact sheet" of gifs

Posted: 2020-03-16T19:46:04-07:00
by fmw42