Ghostscript – Convert PDF Cover/Page into PNG

I want to convert the cover page of a PDF into an image. so far, i have heard about 2 image processing tools in Linux. They are

  • ImageMagick
  • Ghostscript


 

For PDF conversion, ImageMagick runs Ghostscript behind the scene. To install Ghostscript in Mac, you can download the dmg @ UPFLYSOFT.

After the installation, you can run the gs command in shell. Here is the command to convert a PDF cover into PNG.

  • gs -q -sDEVICE=pngalpha -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 -r300 -sOutputFile=cover.png sample.pdf

 

You can even convert the image to mono color by simple modify the sDEVICE parameter to pngmono. If you want to convert other pages, just modify the dFirstPage and dLastPage parameters. And if you want to know the available sDEVICE, enter the following command.

  • gs -h

 

Thanks Scott @ Moving to Freedom

Done =)

Reference:

2 thoughts on “Ghostscript – Convert PDF Cover/Page into PNG”

  1. For batch conversion from or to pdf these are the mightiest tools you can find. If you want to have a graphical user interface instead you can give the gimp a try: A mighty graphics program that for reading PDF files will internally use ghostscript, too.

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.