Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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