Skip to content

Instantly share code, notes, and snippets.

@innermond
Created September 21, 2014 14:03
Show Gist options
  • Select an option

  • Save innermond/d6cd1985124af8a782fd to your computer and use it in GitHub Desktop.

Select an option

Save innermond/d6cd1985124af8a782fd to your computer and use it in GitHub Desktop.
Extract a range o pages $2 - $3 from a PDF document $1 as PNG images prefixed with $4 - for quality the script saves images with high resolution and scales them down
#!/bin/bash
tempdf=$(tempfile)
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=$2 -dLastPage=$3 -sOutputFile=$tempdf $1
gs -dNOPAUSE -sDEVICE=png16m -r600 -dDownScaleFactor=3 -dBATCH -dSAFER -sOutputFile="$4-$2-%00d.png" $tempdf
rm -f $tempdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment