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
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: