[ILUG] shell scripts and graphics...
kevin lyda
kevin at suberic.net
Wed Nov 24 14:08:10 GMT 1999
my reviews were made much simpler (and smaller) by cropping the vmware
borders. however i didn't do them by hand. one of the great things
about unix is shell scripting and how small menial tasks can be
automated. redhat comes with what used to be in a tarball called netppm
orsomething - i guess it's now in the libgr project and is in the
libgr-progs rpm. very useful.
anyway, on the script side, the down side is scripts can get downright
ugly.
on that note, here's the script i used in case it might be of use to
anyone. it's smaller then an an snipped cookbook spam, so i suppose
it's ok to include!
kevin
----blurb----
run this as script.sh foo.jpeg
it must be run *IN THE DIR* where the script is. it will copy the
original file into a directory called old in that directory.
this is quick and dirty. it did a single task for me very quickly (vs.
the two hours or so i'd probably need to spend on it.). maybe it can
help you, but read it first!
----snip here----
#!/bin/sh
jpeg=$1
old=old/$jpeg
base=`basename $jpeg .jpeg`
ppm=${base}.ppm
x=9
y=34
if [ ! -d old ]; then
mkdir old || exit 2
fi
# echo $jpeg $old $base $ppm
djpeg $jpeg > $ppm
width=`head -2 $ppm | tail -1 | cut '-d ' -f1`
height=`head -2 $ppm | tail -1 | cut '-d ' -f2`
# echo $width $height
width=`expr $width - $x - 9`
height=`expr $height - $y - 26`
# echo $width $height
mv $jpeg $old
pnmcut $x $y $width $height $ppm | cjpeg > $jpeg
rm $ppm
----snip here----
--
kevin at suberic.net Nutrition Facts
fork()'ed on 37058400 Puns: 100% RDA (% good puns: 0)
More information about the ILUG
mailing list