Skip to Content.
Sympa Menu

baslinux - Re: [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: Re: [BL] script to shrink photos
  • Date: Tue, 27 Dec 2005 19:45:01 +0000 (UTC)

On Mon, 26 Dec 2005, David Moberg wrote:

On 12/26/05, sindi keesan <keesan AT sdf.lonestar.org> wrote:
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)

Are you sure that it is pamscale? I do not have pamscale here, (not
sure what version of netpbm I have) but I do have pnmscale, which
appears to work with this script.

pnmscale (it replaced pamscale a while ago).


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 .... ?

jpegtopnm infile.jpg | pnmscale .5 | pnmtojpeg >outfile.jpg

You need to put this in a 'for' loop in order to process multiple files
at once.

I got this far but I don't want all the files to end up with the same name (outfile.jpg). Can I generate a new name based on the old one somehow? infile.jpg converted to infile2.jpg ? I tried with $1.jpg but it added another .jpg (file.jpg.jpg) and with $1 but then $1scale would be infile.jpg.scale. Most of my experiments gave 0 length files.

To use netpbm, first I converted jpeg to pnm, then shrank the pnms, then I combined (with pamcat -lr and then -tb -white) 6 images into one, after trimming them all to 1200x960 so I could print 6 on a page, letter size with 1/4" margins left and right. 8"x 300 dpi = 2400 (2 photos wide).
I could already fit three photos high (3x960 is less than 10.5x300).

I converted the pnm to ps with pnmtops (netpbm) and it told me
Warning: image too large for page, rescaling to 0.255'
(What did this do?) but produced one 42MB file. (This should only be done on a fast computer with lots of hard drive - 99.8% cpu use on my 600MHz).

My HP 870cse printed (without red, and with thin white horizontal stripes) K-Mart can do better for 20 cents. Use cdjcolor (not cdeskjet - 'unable to open the initial device' is what printed that way).

The Epson stylus (stcolor) says it is 'out of paper' (so does my HP LJ6L -- wrong cables, or do they need something other than SPP/normal in CMOS?) and the black is clogged (Epson, nozzles not part of cartridge) so I converted back from pnm to jpeg to put on a floppy disk and take to K-mart.

pnmtojpeg produced a file that was just over 1.457K (floppy disk size).

pnmtojpeg2k makes smaller files but it 'failed to encode the JPEG 2000 image Rc=-1'

pnmtojpeg -optimize produced a 1.452K file, same quality, in a few more seconds. This is larger than my 6 original 200-210K jpg images and the (default) conversion was only 75%. (100% produced a 5MB file). Is there some way to combine 6 jpegs losslessly?

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.

Don't try this on a 486. Rotating images takes more memory and crashes a
486 with 24MB RAM and no swap file.

Does it use less memory if you use a smaller image?

I think it worked with a 640K photo when I shrank the image from 1280 before rotating. I won't try rotating anything on a slow computer again.

David




Archive powered by MHonArc 2.6.24.

Top of Page