Skip to content

Instantly share code, notes, and snippets.

@jesusgoku
Created August 5, 2015 06:15
Show Gist options
  • Save jesusgoku/a02d351798f33e5977c1 to your computer and use it in GitHub Desktop.
Save jesusgoku/a02d351798f33e5977c1 to your computer and use it in GitHub Desktop.
Extract first page from PDF files and convert to JPEG
#!/usr/bin/env bash
for f in *.pdf; do
PDF_OUPUT=`echo "$f"| sed 's/\.pdf$/_0.pdf/'`
JPEG_OUPUT=`echo "$f"| sed 's/\.pdf$/.jpeg/'`
pdftk "$f" cat 1 output "$PDF_OUPUT"
convert -trim "$PDF_OUPUT" "$JPEG_OUPUT"
rm -f "$PDF_OUPUT"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment