Ok I rewrote it a bit to allow for transparent background and I think it
works nicely. I changed it to ask whether the user wants a transparent
background right after entering the output resolution. If transparent =
yes, then it does not prompt for an output format but instead uses png
by default. (It would be easy enough to add a prompt inside the if --
fi construct asking whether the transparent format should be png or gif,
I guess.) If transparent = no, then it asks what the final image format
should be and then continues normally and outputs jpeg, tiff, or png.
Here's the revised script:
#!/bin/bash
#*****************************************************#
# Script for making image files from lilypond source #
# suitable for use as musical examples to insert in a #
# document or web page. #
#*****************************************************#
# 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 -n "Would you like a transparent background? (yes or no): "
read TRANSPARENCY
if [ "$TRANSPARENCY" == "yes" ]
then
cd $OUTDIR
lilypond --format=png -dresolution=$RES $srcfile
pngtopnm $STEM.png > $STEM.pnm
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm
pnmtopng -transparent '#ffffff' $STEM-cropped.pnm > $STEM.png
eog $STEM.png
else
# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff): "
# gather format input
read FORMAT
cd $OUTDIR
lilypond --format=png -dresolution=$RES $srcfile
pngtopnm $STEM.png > $STEM.pnm
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm
pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT
# 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
Patrick Horgan wrote:
pnmtopng has the transparent argument, but pnmtotiff and jpeg don't
since they don't support transparency...so, using your script, if you
want transparency, you have to choose png for the output, then on the
translation step from ppm just add the appropriate flags. I just tried
it adding a quick -transparent '#ffffff' to the command line and then
selecting png so it would work. It worked like a charm:)
Patrick
Re: the footers: are you talking about the "engraving by Lilypond"
footer or some other thing?
Yep. Or the copyright statement, or the typesetter statement, et.al.
Patrick
--
Jonathan Kulp
http://www.jonathankulp.com
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user