Make GIF animations from postscript files

Install LaTeX2HTML (instructions here) to get the pstoimg script.

Install GIFMerge:

wget http://www.the-labs.com/GIFMerge/gifmerge.tar.gz
mkdir gifmerge
cd gifmerge
tar xzvf ../gifmerge.tar.gz
make
sudo cp gifmerge /usr/local/bin ## or somewhere else in your $PATH

Copy the source below and paste into a file called psmovie somewhere in your $PATH.

cd /usr/local/bin
sudo vi psmovie  ## paste source 
chmod +x psmovie

psmovie

#!/bin/sh
#
# Run "psmovie idl.ps" to make an movie of all of the pages in idl.ps 
# Run "psmovie idl.ps -flip r90" for Landscape plots
# 
# Take out the last "open -a" line on Linux or if you don't have Quicktime7 installed
# 
root=`echo $1 |sed "s/\.ps//"`

echo "pstoimg -antialias -crop a -multipage -type gif $2 $3 ${root}.ps"
pstoimg -antialias -crop a -multipage -type gif $2 $3 "${root}.ps"

echo "gifmerge -08 ${root}?.gif ${root}??.gif > ${root}_anim.gif"
gifmerge -08 ${root}?.gif ${root}??.gif ${root}???.gif > "${root}_anim.gif"

open -a "quicktime player 7" "${root}_anim.gif"

The example animation shown above was created using the following:

idl

set_plot,'ps'
!P.thick=3
!x.thick=3
!y.thick=3
!x.range=[-1,1]*1.1
!y.range=[-1,1]*1.1
for x = -1.,1,0.1 do plot,x*[1,1],sqrt(1-x^2)*[1,1],psym=2
for x = 1.,-1,-0.1 do plot,x*[1,1],-1*sqrt(1-x^2)*[1,1],psym=2
device,/close
exit

psmovie idl.ps
Advertisements
This entry was posted in Tips and tagged , . Bookmark the permalink.

2 Responses to Make GIF animations from postscript files

  1. Brandon Tingley says:

    My .gif doesn’t repeat. do you have any suggestions?

    • Brandon Tingley says:

      OK, a fix: change the gifmerge command to:

      gifmerge -l0 -08 ${root}?.gif ${root}??.gif > “${root}_anim.gif”

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