Forrest logo
back to the gs tool

gs:tldr:c84cf

gs: 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}
try on your machine

This command is using the Ghostscript utility (gs) to convert a PDF file to JPEG images. Here is a breakdown of each parameter:

  • -dQUIET: Suppresses any non-error messages. It runs silently.
  • -dBATCH: Exits Ghostscript after processing the input files.
  • -dNOPAUSE: Disables the prompt and pausing between each page during processing.
  • -sDEVICE=jpeg: Sets the output device to be JPEG format.
  • -r150: Sets the output resolution to 150 dots per inch (dpi).
  • -dFirstPage=${1}: Specifies the first page of the PDF to convert. ${1} refers to the first command-line argument passed to the script using this command.
  • -dLastPage=${3}: Specifies the last page of the PDF to convert. ${3} refers to the third command-line argument passed to the script using this command.
  • -sOutputFile=${output%d-jpg}: Sets the output file name format for the JPEG images. ${output%d-jpg} creates a file name with a placeholder for page numbers.
  • ${input-pdf}: Specifies the input PDF file to convert. ${input-pdf} refers to the input file passed as a command-line argument.

Overall, this command takes a PDF file as input and converts a specific range of pages to JPEG images with a resolution of 150 dpi. The output files will be named based on a specified pattern.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the gs tool