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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bp2017
Posts: 3
Joined: 2019-02-24T18:51:55-07:00
Authentication code: 1152

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

For PDF files, you need to have Ghostscript installed? Is it there? Does magick -version list gs?
bp2017
Posts: 3
Joined: 2019-02-24T18:51:55-07:00
Authentication code: 1152

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

Post 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).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
Post Reply