Skip to content

Instantly share code, notes, and snippets.

@kcole93
Last active July 21, 2021 17:50
Show Gist options
  • Save kcole93/c0b5e5299de5bdff9de9e835139fc8e8 to your computer and use it in GitHub Desktop.
Save kcole93/c0b5e5299de5bdff9de9e835139fc8e8 to your computer and use it in GitHub Desktop.
Generate PDF Thumbnails

Generate Thumbnail for a Single PDF

To create image thumbnails from a PDF document, run this in a terminal window:

convert -thumbnail x300 -background white -alpha remove input_file.pdf[0] output_thumbnail.png

Generate Thumbnails for an Entire Folder of PDFs

for f in *.pdf; do convert -thumbnail x300 -background white -alpha remove "$f"[0] "${f%.pdf}.png"; done

Parameters

  • -thumbnail: optimizes png creation for speed and strips metadata
  • x300: Sets the thumbnail height, maintaining aspect ratio
  • -background white: Sets the background of the thumbnail to white
  • -alpha remove: Removes the alpha channel from the thumbnail output
  • input_file.pdf: the PDF file to use as input
  • [0]: The page number of the input file to use for the thumbnail

Source: Duncan Lock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment