This looks really great but it failed when I tried to run it. I must have messed it up when copying it over to my editor. Would you mind attaching a working copy as a file instead of copying into the email?

Also, I think we crossed paths in our most recent posts about this. I sent a revised version that allowed for a choice between gif and png on transparent images and also fixed a problem I had introduced related to tiff format. I'll attach most recent script.

I really like the flexibility your modifications introduce, being able to bypass all the prompts. I like the prompts for myself because I have a hard time remembering flag arguments sometimes, but even I can probably remember these. Besides that I can use your modifications to learn some tricks about scripting--clearly you actually *know* how to script! I'm a total newb but am having fun learning. :)

Jon

Patrick Horgan wrote:
Here's a modified version of Jonathan's unix/linux script that supports arguments which are:

-t or --transparency : output format forced to png and you get transparency

-r=N or --resolution==N      : (example -r=72) set resolution

-f=FORMAT or --format=FORMAT : (example -f=jpeg) set output format


So, if the script is named lilytoimage, you could do:

lilytoimage -r=72 -t lilydir/myfile.ly

or

lilytoimage -r=111 -f=tiff lilydir/myfile.ly


If you don't specify any of those arguments then it works just like it did before, except it will also ask about transparency. I don't have a Mac to test on, so I didn't mess with the Mac version. Let me know if there's any bugs;)

Patrick

--
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

Reply via email to