January 1, 2010

PDF to JPEG Image Conversion Shell Script

Filed under: Linux,Sample code,Shell Script — mariojump @ 5:51 am
Tags: ,

Pdfimages can generate JPEG image files from a PDF file. Each page is converted to a JPEG file.

Using pdfimages, I wrote a shell script which generates JPEG image files for all PDF files in the current directory.

$ cat

# Create an array of the PDF files in the current directory.
files=(`ls -1 *.pdf`)

# Iterate for each PDF file in the array
for file in ${files[@]}
  image_root=`echo $file |sed -e "s/\.pdf//"`
  /usr/bin/pdfimages -j $file $image_root

exit 0

Blog at