Turning a PDF into an animated GIF

Today I was asked to take a bunch of PDF files (essentially frames of the animation) into an animated GIF. This is actually a fairly simple task todo with [imagemagick] and its fast too. Simply all you have todo (assuming the PDF, or other image files etc are in order) is:

convert -delay 20 -loop 0 frame*.pdf output.gif

The -delay 20 specifies the time between frames and the -loop 0 tells the image to loop forever.
Quite nice really (the animation is for a conference and so I won’t post it).
The only issue I had is I wanted it to stay on the last frame for a while, but this was simply accomplished by a bit of bash before running the above:

for i in $(seq 28 1 38)
cp -r frame27.pdf frame$i.pdf

Thus this took frame 27 and copied it in a sequence from 28 to 38. Sweet.
Finally I was asked to put two animations next to each and this can be done by using the append functionality:

for i in $(seq 01 01 38)
convert frameset1/frame$i.pdf frameset2/frame$i.pdf +append output$i.pdf

This adds the same frame number from each set next to each other in one larger image. Once this is done it is a simple procedure of running the earlier animation script on the newly created pdfs.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: