• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

gs Command Examples in Linux

by Deepika

Ghostscript (gs) is a command-line interpreter for PostScript and PDF files. It is an open-source software developed by Aladdin Enterprises, now maintained by Artifex Software. Ghostscript can be used to convert PostScript and PDF files to other formats, such as raster images (JPEG, PNG, etc.) and to perform other operations on the files, such as adding watermarks, creating PDFs from multiple files, and more.

Ghostscript can be used to convert PostScript and PDF files to a wide variety of image formats, such as TIFF, JPEG, PNG, and more. For example, the following command can be used to convert a PDF file to a PNG image:

# gs -sDEVICE=png16m -dNOPAUSE -dBATCH -dSAFER -sOutputFile=output.png input.pdf

It can also be used to create a pdf from multiple files, for example:

# gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=output.pdf input1.ps input2.ps

Ghostscript can also be used to perform other operations on PostScript and PDF files, such as adding watermarks, creating PDFs from multiple files, and more. Ghostscript is widely used by many applications, such as PDF viewers, printers and print servers, and more.

gs Command Examples

1. To view a file:

# gs -dQUIET -dBATCH file.pdf

2. Reduce PDF file size to 150 dpi images for reading on a e-book device:

# gs -dNOPAUSE -dQUIET -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=output.pdf input.pdf

3. Convert PDF file (pages 1 through 3) to an image with 150 dpi resolution:

# gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -dFirstPage=1 -dLastPage=3 -sOutputFile=output_%d.jpg input.pdf

4. Extract pages from a PDF file:

# gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

5. Merge PDF files:

# gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf

6. Convert from PostScript file to PDF file:

# gs -dQUIET -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.ps

Filed Under: Linux

Some more articles you might also be interested in …

  1. shred: command not found
  2. setfacl Command Examples in Linux
  3. How to set custom device names using udev in CentOS/RHEL 7
  4. EMC PowerPath Powermt Commands (Cheat Sheet)
  5. How to Log dropped packets using firewalld in CentOS/RHEL 7
  6. CentOS / RHEL : How to get the date and time of executed command in the history command output
  7. jpegtran for image optimization
  8. “530 Non-anonymous sessions must use encryption” – while using curl
  9. cryptcat: command not found
  10. A File Is Claimed to Be Disappearing – How to monitor a file for deletion in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • dircolors: Output commands to set the LS_COLOR environment variable and style ls, dir, etc
  • dillo: A lightweight web browser intended for slow computers
  • dig: DNS lookup utility
  • diffstat: Create a histogram from the output of the diff command

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright