Command a Ghost

Everyone working with graphics in a serious way with a computer should be acquainted with Ghostscritpt. For those who are not, it is a an interpreter suite for PostScript and Portable Document Format: I will not cover it in depth here, but you can learn more at the related Wikipedia article or visiting the official website.
It is a very powerful and versatile tool and one could write books about, but in this post I will focus on one conversion I personally found very useful , but not particularly user-friendly.
So I am publishing this for my own exercise and with the hope of helping other users.

Take the following command:

gswin64c.exe -dNOPAUSE -dBATCH -r600 -sDEVICE=tiff24nc -sCompression=lzw -sOutputFile=scansioni%d.tif scansioni.pdf

comprised of several parts

  • gswin64c.exe
    the executable name: in this case is the 64-bit Windows one.
    You should replace it with the program file appropriate for you OS and architecture
  • -dNOPAUSE
    instruct the parser not to pause and ask for input at the page breaks
  • -dBATCH
    GS will exit at the end of the process instead of entering in interactive loop reading PostScript commands.
    Please note that both -dNOPAUSE and -dBATCH can be replaced by the single -o
  • -r600
    output resolution in DPI. Writing just one value will set vertical and horizontal resolution the same, otherwise you can use the form -rXRESxYRES
  • -sDEVICE=tiff24nc
    the output device, in this case a TIFF file with color depth 24bits
    Other common values could be -sDEVICE=tiffgray or -sDEVICE=jpeg.
  • -sCompression=lzw
    the compression to use for the TIFF file, in this case the Lempel–Ziv–Welch algorithm
  • -sOutputFile=output%d.tif
    the filename of the output: the use of %d will generate one file for each page in the original document appending number to the name output
  • input.pdf
    the original PDF file to read from

this blog post act as a sort of cheat sheet for rapid reference, but complete information on how to use GS can be found at How to use Ghostscript and Details of Ghostscript output devices.

Advertisements

Author: lucamauri

First and foremost a geek and a Trekker, Luca Mauri is employed as an IT Manager. A Space Exploration enthusiast, avid reader and hobbyist photographer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s