Skip to content

Instantly share code, notes, and snippets.

@treetrum
Created January 24, 2018 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treetrum/661f5ea75d37a5f16f56040654216cf0 to your computer and use it in GitHub Desktop.
Save treetrum/661f5ea75d37a5f16f56040654216cf0 to your computer and use it in GitHub Desktop.
Get a JPEG of the first page of a PDF file
# Extracts the first page of the PDF
gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="page1.pdf" -dFirstPage=1 -dLastPage=1 {pdf-file-name}
# Converts that 1 page PDF into a JPEG
convert "page1.pdf" {pdf-file-name}.jpg
# Delete the 1-page pdf
rm "page1.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment