[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: png cropping
From: |
Jonathan Kulp |
Subject: |
Re: png cropping |
Date: |
Wed, 17 Sep 2008 23:59:38 -0500 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080724) |
Patrick,
Sorry to keep posting new versions but I found another problem with my
previous one, which is that there's no ppmtopng command, so I had to add
another if-then statement to fix it. I also learned a couple of things
from your script that are very useful (e.g. accepting equally "yes," "Y"
or "y") and changed the prompt to a more usual style: from (yes/no) to
(y/N).
I've now tried all variations and they all work. Now if you can
integrate your mods to accept arguments at the command line that'd be
sweet. Thanks for being interested in this :)
Jon
script:
#!/bin/bash
# get filename from first argument
srcfile="`basename $1`"
# get filename without .ly extension
STEM="`basename $1 .ly`"
# determine output directory
OUTDIR="`dirname $1`"
# ask for output resolution
echo -n "Enter output resolution in DPI (72, 100, 300, 600, etc.): "
# gather resolution input
read RES
echo "Resolution is set to $RES"
echo -n "Would you like a transparent background? (y/N): "
read TRANSPARENCY
if [[ ( "$TRANSPARENCY" == "yes" ) || ( "$TRANSPARENCY" == "y" ) || (
"$TRANSPARENCY" == "Y" )]]
then
echo "Background is set to transparent"
echo -n "Enter desired output format (png or gif): "
read TRANSFORMAT
echo "Output format is set to $TRANSFORMAT"
cd $OUTDIR
lilypond --format=png -dresolution=$RES $srcfile
pngtopnm $STEM.png > $STEM.pnm
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm
if [ "$TRANSFORMAT" == "png" ]
then
pnmto$TRANSFORMAT -transparent '#ffffff' $STEM-cropped.pnm >
$STEM.$TRANSFORMAT
else
ppmto$TRANSFORMAT -transparent '#ffffff' $STEM-cropped.pnm >
$STEM.$TRANSFORMAT
fi
eog $STEM.$TRANSFORMAT &
else
# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff, gif, pcx,
bmp, pgm): "
# gather format input
read FORMAT
echo "Output format is set to $FORMAT"
cd $OUTDIR
lilypond --format=png -dresolution=$RES $srcfile
pngtopnm $STEM.png > $STEM.pnm
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm
if [[ ( "$FORMAT" == "tiff" ) || ( "$FORMAT" == "png" ) ]]
then
pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT
else
ppmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT
fi
# open final image as background process in "Eye of Gnome" Image Viewer
eog $STEM.$FORMAT &
fi
# removes pnm and ps files
rm *.pnm $STEM.ps
lilyimage
Description: Text document
- Re: png cropping, (continued)
- Re: png cropping, Patrick Horgan, 2008/09/18
- Re: png cropping, Mark Knoop, 2008/09/19
- Re: png cropping, Jonathan Kulp, 2008/09/19
- Re: png cropping, Patrick Horgan, 2008/09/19
- Re: png cropping, Jonathan Kulp, 2008/09/17
- Re: png cropping, Patrick Horgan, 2008/09/17
- Re: png cropping, Jonathan Kulp, 2008/09/17
- Re: png cropping,
Jonathan Kulp <=