[juneau-lug] Resizing jpegs

  • From: James Zuelow <e5z8652@xxxxxxxxxx>
  • To: jlug <juneau-lug@xxxxxxxxxxxxx>
  • Date: Sat, 24 Jul 2004 17:45:02 -0800

Here's a quick one, basically stolen from the latest Linux Journal.

My daughter just had her 4th birthday, and our digital camera takes images that 
are pretty large - 1280x960 normally.  A zip of the images we took was 7.5MB, a 
little big for e-mail.  Since I had just finished reading the article on image 
tools, I decided to resize the images all at once.  I chose 640x480 as being a 
good size (which shrunk the zip to 980k), and then thought about all the time 
I'd spent resizing images for my personal web page (there's a big reason it 
hasn't been updated in a while - image manipulation is one of them).  I decided 
to script it so I could decide what the image size could be every time I ran 
the script. 

Here's the script if you're interested.  It depends on netpbm (probably in your 
default install) and will resize *.jpg files to fit into the dimensions you 
specify, copying the files instead of replacing them. 

Cheers,

James

----script follows----

#!/bin/bash
####################################
# rescalejpeg.sh
# small script to scale jpeg files to fit into an arbitrary box
# James Zuelow  //  Juneau Linux Users Group
# 24 July 2004
####################################
echo -n "Select the maximum horizontal dimension in pixels: "
read xdim
echo -n "Select the maximum vertical dimension in pixels: "
read ydim
for file in `ls *.jpg`
do
        echo ${file}
        # if the message wraps, the following is all one line
        jpegtopnm  ${file} 2> /dev/null | pnmscale -verbose -xysize ${xdim} 
${ydim} | pnmtojpeg > small${file}
        # if the message wraps, the previous is all one line
        echo "----------"
done

----script end----

------------------------------------
This is the Juneau-LUG mailing list.
To unsubscribe, send an e-mail to juneau-lug-request@xxxxxxxxxxxxx with the 
word unsubscribe in the subject header.

Other related posts: