Skip to content

Instantly share code, notes, and snippets.

@fajran
Created July 6, 2009 07:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fajran/141313 to your computer and use it in GitHub Desktop.
Save fajran/141313 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Create thumbnails of a PDF file
#
# Author: Fajran Iman Rusadi <fajran@gmail.com>
# License: Public domain
# Requirements: poppler-utils imagemagick
# Usage: pdf2thumbnail input.pdf output-prefix- size
# e.g. pdf2thumbnail input.pdf thumbnail- 400
INPUT=$1
PREFIX=$2
SIZE=$3
TOTAL=`pdfinfo $INPUT | grep ^Pages | awk '{ print $2 }'`
echo "Total pages: $TOTAL"
for i in `seq 1 $TOTAL`
do
pdftoppm -f $i -l $i $INPUT | convert -thumbnail $SIZE - $PREFIX$i.png
echo -n "$i "
done
echo
echo done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment