Extracting images from PDF files to JPEG

Here’s an interesting script for Linux and command-line interface lovers to extract images from PDF files to JPEG format. Thanks to Guillaume Pratte from the GULUS.

I am posting this untested for the sake of making it available publicly

This script requires xpdf-utils (for pdfimages) and imagemagick (for convert). It’s published under a public domain licence.

#!/bin/sh

if [ -z "$1" ];
then echo "Usage: $0 nom_album.pdf";
fi

ALBUM=`basename "$1" .pdf`

mkdir "$ALBUM"
cd "$ALBUM"
pdfimages "../$1" "$ALBUM"
for i in *.ppm; do convert -quality 90 "$i" jpg:`basename "$i" ppm`jpg; done
rm *.ppm

echo
echo "PDF file images extraction completed!"