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: David Moberg <davidjmoberg AT gmail.com>
  • To: baslinux AT lists.ibiblio.org
  • Subject: Re: [BL] script to shrink photos
  • Date: Tue, 27 Dec 2005 13:34:53 -0800

sindi keesan wrote:

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

I would modify Steven's script to put the output files into a different
directory:

cd indirectory
for i in * ; do jpegtopnm $i | pnmscale .5 | pnmtojpeg
>../outdirectory/$i ; done

Or you can use sed to produce more complex filename variations:

for i in * ; do jpegtopnm $i | pnmscale .5 | pnmtojpeg >$(echo -n $i |
sed -e "s/\.jpg/-new.jpg/g") ; done

This sed script searches for '.jpg' (the dot needs to be 'escaped') in
filenames and replaces it with '-new.jpg'.

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

It appears to have scaled down the page image because it was too
big. I wonder what 0.255' is? .255 feet is 7.77 centimeters.

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

Maybe they do. Do they behave the same way in DOS? If not, it
might be a bug in the Linux lp driver.

> 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'

jpeg2k is incompatible with the ordinary jpeg format.

David




Archive powered by MHonArc 2.6.24.

Top of Page