I am using TexShop on a Mac, which handles all of the rendering for me, but have been asked by a colleague to find the command(s) that would render the LaTex document as a PNG instead of PDF.

By way of example, on linux it would be

$ pdflatex file.tex
$ gs -sDEVICE=pnggray -sOutputFile=card.png -dNOPAUSE -r1200 file.pdf quit.ps

(Note: the -r1200 will generate an image 4x larger than used, since it will be scaled down to produce an anti-aliased image).

Thank you & kind regards.

  • 2
    OSX is unix, so you can probably issue the GS command the same way. Jun 11, 2013 at 16:08
  • You can use convert. Jun 11, 2013 at 16:10
  • where did the file quit.ps come from in the command you show? Is this command supposed to convert a PDF file to PNG image? So a 100 pages pdf file will be converted to one png image? becuase when I just tried it on 16 pages pdf file: gs -sDEVICE=pnggray -sOutputFile=card.png -dNOPAUSE -r1200 index.pdf then when it is done, I get the GS> prompt. Now I typed quit and then looked at card.png but it only shows the first page of the pdf file only. How is this supposed to work?
    – Nasser
    Jun 11, 2013 at 17:00
  • There are two commands: sips and convert.
    – Pouya
    Jun 11, 2013 at 18:32

1 Answer 1


The Mac OS is Unix-based, so at the Terminal

pdflatex <filename> && gs -sDEVICE=pnggray -sBATCH -sOutputFile=<filename>.png -dNOPAUSE -r1200 <filename>.pdf

should work just fine. (Fill in your <filename>, of course.)

  • is this equivalent to opening the PDF in Preview and exporting as png?
    – Rax Adaam
    Jan 26, 2017 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.