Ok I changed a couple of things to make it even more flexible. I
changed pnmto__ to ppmto__, giving quite a few more output options.
I've suggested a few in the script. Also added an option to choose
either gif or png when choosing transparent background. this is fun :)
Jon
script attached this time...
Patrick Horgan wrote:
Jonathan Kulp wrote:
I'm guessing that one of the netpbm tools will handle transparency,
it's just a matter of figuring out which one. Didn't this come up on
a recent thread? I seem to remember trying it out on something and
getting a transparent background. When I get some time later I'll
look into it. It would be simple enough to add a prompt asking if
you'd like a transparent background, I guess.
Now that you mention it that rings a bell with me too! I'll have to
search---
giftoppm foobar.gif | ppmtogif -transparent '#rgb' > fooquux.gif
works if you want gif. First translate to ppm, then translate back to
gif with the -transparent flag specifying which color, (in this case
#fff) will be transparent.
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:)
--
Jonathan Kulp
http://www.jonathankulp.com
#!/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
echo -n "Enter desired output format (png or gif): "
read TRANSFORMAT
cd $OUTDIR
lilypond --format=png -dresolution=$RES $srcfile
pngtopnm $STEM.png > $STEM.pnm
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm
ppmto$TRANSFORMAT -transparent '#ffffff' $STEM-cropped.pnm >
$STEM.$TRANSFORMAT
eog $STEM.$TRANSFORMAT &
else
# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff, gif, pcx, bmp): "
# 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
ppmto$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
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user