3

I'm animating a gif with Imagemagick, I'm doing animate *.JPG, and that repeats the animation. But I would like it to go do "pic1, pic2, pic3, pic2, pic1" and repeat, so that it goes back and forth. How can that be done, preferably from a cli?

3
  • How many images are there actually in your sequence?
    – 8128
    May 1, 2011 at 19:01
  • 12, but I do this quite often and sometimes there is more. May 1, 2011 at 19:03
  • A piggyback question to future readers (if I may … sorry if I may not): does anyone know the official term for this? "Pendulum loop" perhaps? It certainly must have a proper name. Sep 23, 2018 at 13:54

4 Answers 4

8

You can just create a new GIF (here, animation.gif) from pic*.jpg.

Animating with a delay between frames of 0 and a back-and-forth that repeats for ever can be done with:

convert pic*.jpg -set delay 10 -reverse pic*.jpg -set delay 10 -loop 0 animation.gif

(assuming your jpgs are arranged in alphanumeric order).

obtained from here: http://www.noah.org/wiki/ImageMagick (not my site).

2
  • You can do the same with an existing GIF, though I can't get the delay to work (but I can modify the delay of the resulting bouncing GIF).
    – jahroy
    Apr 5, 2018 at 19:44
  • This makes the resulting GIF twice as long. Isn't it possible to just hint to the player that is should bounce the frames, instead of just looping?
    – Bram
    Jul 19, 2022 at 14:55
2

How about this:

Just correcting the code above.

    cp pic2.jpg pic4.jpg && animate *.jpg

Otherwise the 1st pic would show twice. I don't know if there is an easier way way to do this.

Even on GIMP we have to add the duplicated images.

1

can you try this ?

cp pic1.jpg pic4.jpg
cp pic2.jpg pic5.jpg
animate *.jpg

just a guess

2
  • That would work, but can't that be done in one command? Embarrassing, but I don't know regular expressions :) May 1, 2011 at 19:00
  • clicker4721 have better solution. I havent worked with imagemagick a lot...
    – Denwerko
    May 1, 2011 at 19:08
1

You should simply do your animation and layer it in order "pic1, pic2, pic3, pic2." In that order to start with. You will achieve the desired results when it repeats. In other words, you're thinking have (for example) 3 frames that go forwards and then backwards. That doesn't work. This will take up more space, but instead you must have four frames that repeat normally.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .