Tuesday, March 11, 2008

Automatically created PDF thumbnails

This is a bash script that creates an ultra-simple web page that previews PDFs. It uses Imagemagick to create the thumbnails.

#!/usr/bin/env bash

echo "<html><body>" > index.html
echo "<h1>PDF List</h1>" >> index.html
for myfile in *.PDF
basename="`basename $myfile .PDF`"
#echo $basename
convert -antialias -colorspace RGB -scale 200x200 $myfile[0] $basename.jpg
echo "<a href="'$myfile'"><img src="'$basename.jpg'" /></a>" >> index.html
echo " " >> index.html

echo "</body></html>" >> index.html