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 23:34:34 +0000 (UTC)

On Tue, 27 Dec 2005, David Moberg wrote:

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

That worked perfectly.

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.

My page it 8.5x11". I have not succeeded in printing it properly and am headed off to Kmart with the optimized jpeg.

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.

I moved cables around for a while and, don't know how, got the Epson working but the black nozzles are clogged. It should be stcolor but it printed much too dark with that gs filter, and with little colored dots. (It may not print 24-bit color, looks like 4-bit to me).

The HP 870cs has one cartridge missing red and yellow, and one missing all the colors. I should try soaking the heads in hot water. It prints 24-bit color with cdjcolor but without the colors. I tried three filters for each printer. There is a deskjet 600 series to try next. If I give up printing in color we can recycle half our printers and use K-Mart for the occasional photo.

netpbm itself prints nicely in mono on both printers (when they are not clogged). Much simpler and faster than gs, no need to convert the image to ps first, or specify anything but resolution and file name and lp0.

The 6L does not respond to any print command any more, even in DOS, with the cable that works elsewhere. It used to print but feed all the sheets at once. The power light comes on.

My dot-matrix printer always works (but not in color, and not fast).

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.

What does this imply? Why can't I encode a pnm to that format?

David




Archive powered by MHonArc 2.6.24.

Top of Page