Skip to Content.
Sympa Menu

baslinux - [BL] script to shrink photos

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: sindi keesan <keesan AT sdf.lonestar.org>
  • To: baslinux AT lists.ibiblio.org
  • Subject: [BL] script to shrink photos
  • Date: Tue, 27 Dec 2005 04:13:37 +0000 (UTC)

Rather than upload megabytes of 200K 1280 res photos, I am using netpbm programs to cut the size to 50K. pamscale reduces X and Y by the same factor as a default (.5 in my case).
I called my script halve.

jpegtopnm $1 > temp1.pnm
pamscale .5 temp1.pnm > temp2.pnm (or big.pnm and small.pnm if you prefer)
pnmtojpeg temp2.pnm > temp.jpg

Halve photo1.jpg produces temp.jpg but I want to get back a photo1.jpg that is the same but 1/4 the size.

I have to rename temp.jpg back to the original file name individually.

I have tried various changes to my script and they all produce 0 length files. I don't think I can output > $1 to end up with the same name file I started with.

How can I at least avoid the step of renaming temp.jpg, and if possible, how can I shrink all the files in a directory with one command or script?

For i in .... ?

No I don't want to use gimp or get broadband. People without broadband will be downloading the images and gimp is X so slower.

The tools are netpbm and BL3 busybox in BL2.

I bet there are several ways to do this.

Pamscale is taking 5-10 seconds per photo and uses 99.8% of cpu but very little memory to scale down (reduce). It must be averaging out the colors of two pixels to make one. Scaling up takes much longer. 500MHz.
Don't try this on a 486. Rotating images takes more memory and crashes a 486 with 24MB RAM and no swap file.

I also used netpbm to combine four 1/4 size pdf pages of the camera manual into one pbm page that I could print (I did this all manually) and next time I will read the manual and make smaller files to start with.
The camera is a year newer than the computer.

keesan AT sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org




Archive powered by MHonArc 2.6.24.

Top of Page