Page 1 of 1

How to easily create a gif from pages of a pdf file?

Posted: 2019-02-24T19:18:20-07:00
by bp2017
Hello, everyone!

Come to the point, I need pages of a pdf to act as frames in a gif file and would appreciate your help.

There are several complicated command-string examples for ImageMagick on TeX Exchange that should do the job but I would rather ask for a simple command-string here instead, since it's easier to build upon a simple string of commands than deciphering more complicated strings.

I tried

Code: Select all

magick test.pdf[1] out.gif
but it results in the following error

Code: Select all

magick.exe : magick.exe: FailedToExecuteCommand `"gswin32c.exe" -q -dQUIET -dSAFER -dBATCH 
-dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" 
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dFirstPage=2 -dLastPage=2 
"-sOutputFile=/AppData/Local/Temp/magick-4680Pb5fSrgDtsyo%d" 
"-f/AppData/Local/Temp/magick-46802QyOuukApiRa" 
"-f/AppData/Local/Temp/magick-46801FbYCtmEwj6L"' (The system cannot find the file specified.)
The pdf file contains 3 pages.

Thank you

Re: How to easily create a gif from pages of a pdf file?

Posted: 2019-02-24T20:44:45-07:00
by fmw42
For PDF files, you need to have Ghostscript installed? Is it there? Does magick -version list gs?

Re: How to easily create a gif from pages of a pdf file?

Posted: 2019-02-25T10:56:39-07:00
by bp2017
fmw42, thank you! I installed Ghostscript and the command-string I posted earlier works now (although the output image is tiny and pixelated, I'll need to experiment with additional commands).

Re: How to easily create a gif from pages of a pdf file?

Posted: 2019-02-25T11:34:18-07:00
by fmw42
To make it larger, add -density XXX before reading the PDF, for example this will be about twice as larger. The default density is 72.

Code: Select all

magick -density 150 test.pdf[1] out.gif