#!/bin/bash
#                      /usr/local/bin/pdf2jpg
# http://crystalfaeries.net/posix/bin/pdf2jpg
# celeste:crystalfaery 2015-06-18 18:06:38+00:00
# pdf2jpg extracts images as .jpg's from .pdf's

case $1 in
--version)	tail -n +4 $0 | head -n 1;;
-V)		tail -n +4 $0 | head -n 1;;
-v)		tail -n +4 $0 | head -n 1;;
-h)	echo "$0 accepts .pdf file descriptors to extract images as .jpg's";;
--help)	echo "$0 accepts .pdf file descriptors to extract images as .jpg's";;
*)	while [ $# -gt 0 ]
	do
		pdfimages -j $1 $(echo $1 | sed 's/\.pdf$//')		# extract	.jpgs
		jpegoptim -t $(echo $1 | sed 's/\.pdf$//')-*.jpg	# optimize the	.jpgs
		shift
	done
	;;
esac


syntax highlighted by Code2HTML, v. 0.9.1