MarioNote

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 pdffiles2jpeg.sh
#!/bin/bash

# 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[@]}
do
  image_root=`echo $file |sed -e "s/\.pdf//"`
  /usr/bin/pdfimages -j $file $image_root
done

exit 0

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.