I have a two-page PDF file that I would like to convert to an animated GIF file. A post on the TeX StackExchange gives the following ImageMagick one-liner:
convert -verbose -delay 50 -loop 0 -density 300 file.pdf file.gif
If I try this on a linux box (convert --version
gives 6.5.4-7 2012-04-10) I get this log:
"gs" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=/tmp/magick-XX30a4nG" "-f/tmp/magick-XX690OkA" "-f/tmp/magick-XX3GCKhu"
/tmp/magick-XX30a4nG[0] PNM 1512x1134 1512x1134+0+0 8-bit DirectClass 9.811mb
/tmp/magick-XX30a4nG[1] PNM 1512x1134 1512x1134+0+0 8-bit DirectClass 9.811mb
file.pdf[0] PDF 1512x1134 1512x1134+0+0 16-bit DirectClass 9.811mb
file.pdf[0] PDF 1512x1134 1512x1134+0+0 16-bit DirectClass 9.811mb
file.pdf=>file-linux.gif[0] PDF 1512x1134 1512x1134+0+0 16-bit Palette PseudoClass 111c 2.620u 0:03
[gs
is GPL Ghostscript 8.70 (2009-07-31)] and it works as expected. But if I try this on my mac, using the ImageMagick suite installed by macports (6.8.0-7 2013-01-04), I get this log:
"/opt/local/bin/gsx" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=/var/folders/kf/t7750q1w8xjcjy0059bpyx180000gq/T/magick-15750GLLaATgky5I1" "-f/var/folders/kf/t7750q1w8xjcjy0059bpyx180000gq/T/magick-15750ljasKifrwJcW" "-f/var/folders/kf/t7750q1w8xjcjy0059bpyx180000gq/T/magick-15750w8mj9AZrkJA8"
/var/folders/kf/t7750q1w8xjcjy0059bpyx180000gq/T/magick-15750GLLaATgky5I1 PNG 1512x1134 1512x1134+0+0 8-bit sRGB 64.5KB 0.050u 0:00.049
file.pdf PDF 1512x1134 1512x1134+0+0 16-bit sRGB 64.5KB 0.000u 0:00.000
file.pdf=>file.gif PDF 1512x1134 1512x1134+0+0 16-bit Palette sRGB 106c 0.410u 0:00.409
[/opt/local/bin/gsx
is GPL GhostScript 9.06 (2012-08-08)]
This time the resulting GIF file has only one frame, the first page of the PDF.
My workaround so far has been to use pdftk file.pdf burst
to split out each page of the PDF to its own file, then convert [options] pg_*.pdf file.gif
. This works fine, but I'd prefer a one-line script.
The mac versions being more recent, I would guess it's a matter of implementation. The only major difference I see between the two is -sDEVICE=pnmraw
for the linux version and -sDEVICE=pngalpha
for the mac. Can I tell convert
to pass options to gsx
?
-sDEVICE=pnmraw
to theconvert
command line options and got an "unrecognized option" response.pdftk file.pdf burst && convert [options pg_*.pdf file.gif
This way, Terminal will run the second command once it has completed the first command you requested.