png cropping

2008-08-19 Thread David Bobroff
I'm LilyPonding a piece which requires a "Notation Key".  The recipient 
of this notation key will be doing a bit of further manipulation of the 
output.  What I need to provide is, at her preference, a PNG closely 
cropped so that she can then position this graphic under some 
introductory text about the piece.  I have been unsuccessful at finding 
information about this in the docs.  I've checked the command-line 
options section and elsewhere but have not found any reference to 
controlling the cropping.


The notation key follows at the end here if anyone wants to see how I've 
done this.  I'm not 100% pleased with the spacing but haven't yet tried 
to adjust it yet.  Suggestions for cropping the output are mostly what 
I'm after, but suggestions for a better way to make the notation key are 
also welcome.


A couple of ideas that I haven't yet explored involve trying 
lilypond-book or OpenOffice with LilyPondTool.


-David

% BEGIN LILYPOND CODE %

\version "2.11.56"

grad = {
\override Glissando #'bound-details #'right #'arrow = ##t
\override Glissando #'arrow-length = #1
\override Glissando #'arrow-width = #0.25   
}

darg = {
\revert Glissando #'bound-details
\revert Glissando #'arrow-length
\revert Glissando #'arrow-width
}


mask = {
\hideNotes
\override Staff.BarLine #'transparent = ##t
\override Staff.TimeSignature #'transparent = ##t
\override Staff.Clef #'transparent = ##t
\override Staff.StaffSymbol #'transparent = ##t

}

wa = \relative c'' {
\mask
c^"wa"
\once\override Staff.TextScript #'extra-offset = #'(0 . -0.75)
s4^\markup{"quick close to open, creating 'wa' sound"}
}

closed = \relative c'' {
\mask
c^"+"
s4^\markup{"closed position"}
}

opened = \relative c'' {
\mask
c^\markup{\musicglyph #"scripts.open"}
s4^\markup{"open position"}
}

openClose = \relative c'' {
\mask
\grad
\override Staff.Glissando #'extra-offset = #'(0 . 2.25)
c^\markup{ \musicglyph #"scripts.open" } \glissando c^+
\once\override Staff.TextScript #'extra-offset = #'(0 . -1)
s4^\markup{"gradually move from open to closed"}
}


closeOpen = \relative c'' {
\mask
\grad
\override Staff.Glissando #'extra-offset = #'(0 . 2.25)
c^+ \glissando c^\markup{ \musicglyph #"scripts.open" }
\once\override Staff.TextScript #'extra-offset = #'(0 . -1)
s4^\markup{"gradually move from closed to open"}
}

ww = \relative c'' {
\mask
\unHideNotes
c8(^"wa" c8^"wa" c8^"wa" c8^"wa")
\once\override Staff.TextScript #'extra-offset = #'(0 . -2)
s4^\markup{"'wa' legato, no tongue when on same pitch"}

}

sung = \relative c'' {
\mask
\unHideNotes
\override Staff.Stem #'transparent = ##t
\override Voice.NoteHead  #'style = #'harmonic-mixed
\override Staff.TextScript #'extra-offset = #'(0 . -2.5)
c4 s4^"sung note"

}

aw = \relative c''{
\mask
c4^\markup{\musicglyph #"scripts.open" \musicglyph #"scripts.stopped"}
\once\override Staff.TextScript #'extra-offset = #'(0 . -1)
s4^\markup{"Very quick open-close effect ('bell tones')"}
}

mmm = \relative c'' {
\mask
\override TrillSpanner #'bound-details #'left #'text = " "
s4 \startTrillSpan s s s4 \stopTrillSpan
\once\override Staff.TextScript #'extra-offset = #'(0 . -1)
s4^\markup{ "'wa' vibrato on long, held-out note"}
}

\score {
\wa
\layout {
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 32)
}
  }
}

\score {
\closed
\layout {
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 32)
}
  }
}

\score {
\opened
\layout {
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 32)
}
  }
}


\score {
\closeOpen
\layout {
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 32)
}
  }
}

\score {
\openClose
\layout {
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 32)
}
  }
}
\score {
\ww
\layout {
%
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 16)
}
%}
  }
}

\score {
\sung
\layout {
\context {
  \Score
  \override SpacingSpanner
#'base-shortest-duration = #(ly:make-moment 1 32)
}
  }
}


\score {
\aw
\layout {
\context {
  \Sco

Png cropping

2017-02-24 Thread Renato Fiorenza
I read in the documentation that it is possible to create a cropped png by 
using "-dbackend=eps -dresolution=600 —png" and inserting this \paper block:

\paper{
indent=0\mm
line-width=120\mm
oddHeaderMarkup = ##f
evenHeaderMarkup = ##f
oddFooterMarkup = ##f
evenFooterMarkup = ##f
}

However, I think the cropping is too heavy. How can I produce a png with some 
nonzero margins? I've tried to add top-margin, bottom-margin, 
top-system-spacing, last-bottom-spacing, left-margin, right-margin, 
paper-width, but none of them seem to work.

Thanks a lot in advance,
  Renato
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-08-19 Thread Graham Percival
On Tue, 19 Aug 2008 14:41:24 +
David Bobroff <[EMAIL PROTECTED]> wrote:

> I'm LilyPonding a piece which requires a "Notation Key".  The
> recipient of this notation key will be doing a bit of further
> manipulation of the output.  What I need to provide is, at her
> preference, a PNG closely cropped so that she can then position this
> graphic under some introductory text about the piece.  I have been
> unsuccessful at finding information about this in the docs.

If it's a single line of music,
  -dpreview
could do the job.  (that's what I use)

The info in AU about lilypond-book might help (inserting lilypond
output into other program), but probably won't, since it's aimed
at producing eps images.  Actually, you might be able to convert
the eps to png using an external program.

Finally, you could play with clip-example, which I believe is now
in NR 3.  But I'm not certain if anybody's rewritten the docs for
them -- I certainly haven't.

Cheers,
- Graham


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Jonathan Kulp
This is an old thread but I found it in my email box and thought I'd 
respond because I've recently written a script to handle this sort of 
thing.  I share with some trepidation since last time I shared a script, 
someone pointed out to me that there was already a lilypond command-line 
option that performed exactly the same thing :)


Ok so this script requires the "netpbm" package of image manipulation 
programs.  Anyone who builds Lilypond from source probably has it 
already, but it's easy to get under Linux and Mac.  for Ubuntu I do 
"sudo apt-get install netpbm" and for mac "sudo port install netpbm".  I 
see that there's a Windows version but I've never tried to install that 
because I rarely use Windows.  So far the script works perfectly for 
Linux and Mac OSX 10.4 (maybe 10.5 but I can't try it b/c I don't have 
one).  A couple of lines are different in the Mac version because of the 
different image viewer and different way of invoking lilypond at the 
command line.


What I find useful about the script is that it prompts the user for the 
desired output resolution and format.  So far I've run it successfully 
at resolutions from 72 to 1200 dpi in png, jpeg, and tiff formats.  I 
suppose you could use any image format for which there is a "pnmto___" 
program, substituting the appropriate text for the format.  The script 
will look for whatever format you type in there.


Note, if you want a musical example suitable for inserting in a 
word-processed doc or web page, you might want to remove or comment out 
the header block of your file.


Once you've saved and made the file executable (I keep it in my /bin 
directory so it's in my $PATH), just do "lilyimage foobar.ly" and enter 
the resolution and format when prompted.


I copy below the Linux and Mac versions.  It would be cool if someone 
made it work on Windows, to :)


Linux version of "lilyimage" 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

# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff): "
# gather format input
read FORMAT

cd $OUTDIR

# run lilypond on file with png output for further processing...
lilypond --format=png -dresolution=$RES $srcfile

# The next commands crop the png file so that
# it only includes the example instead of an entire page.
# First convert image to pnm for processing with netpbm tools
pngtopnm $STEM.png > $STEM.pnm

# crop all the white space off
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm

# convert to end format
pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT

# removes pnm and ps files
rm *.pnm $STEM.ps

# open final image as background process in "Eye of Gnome" Image Viewer
eog $STEM.$FORMAT &

%%%

Mac version of 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

# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff): "
# gather format input
read FORMAT

cd $OUTDIR

# run lilypond on file with png output for further processing...
/Applications/LilyPond.app/Contents/Resources/bin/lilypond --format=png 
-dresolution=$RES $srcfile


# The next commands crop the png file so that
# it only includes the example instead of an entire page.
# First convert image to pnm for processing with netpbm tools
pngtopnm $STEM.png > $STEM.pnm

# crop all the white space off
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm

# convert to end format
pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT

# removes pnm and ps files
rm *.pnm $STEM.ps

# open final image as background process in "Eye of Gnome" Image Viewer
open -a preview $STEM.$FORMAT



Graham Percival wrote:

On Tue, 19 Aug 2008 14:41:24 +
David Bobroff <[EMAIL PROTECTED]> wrote:


I'm LilyPonding a piece which requires a "Notation Key".  The
recipient of this notation key will be doing a bit of further
manipulation of th

Re: png cropping

2008-09-17 Thread Patrick Horgan

Jonathan Kulp wrote:
This is an old thread but I found it in my email box and thought I'd 
respond because I've recently written a script to handle this sort of 
thing.  I share with some trepidation since last time I shared a 
script, someone pointed out to me that there was already a lilypond 
command-line option that performed exactly the same thing :)
This is wonderful   If there was a way from the lilypond command 
line to suppress a footer that would make it even better.  We wouldn't 
see things like snippet 464 which has a snippet, a huge amount of white 
space, and then a footer.  Of course you can go into your favorite 
editor and crop manually, but if the footer wasn't on there, this script 
could handle it automagically, and instead of having to go in and edit 
the lilypond file to get rid of the footer, could just invoke lilypond 
with the appropriate command line;)


Patrick


Ok so this script requires the "netpbm" package of image manipulation 
programs.  Anyone who builds Lilypond from source probably has it 
already, but it's easy to get under Linux and Mac.  for Ubuntu I do 
"sudo apt-get install netpbm" and for mac "sudo port install netpbm".  
I see that there's a Windows version but I've never tried to install 
that because I rarely use Windows.  So far the script works perfectly 
for Linux and Mac OSX 10.4 (maybe 10.5 but I can't try it b/c I don't 
have one).  A couple of lines are different in the Mac version because 
of the different image viewer and different way of invoking lilypond 
at the command line.


What I find useful about the script is that it prompts the user for 
the desired output resolution and format.  So far I've run it 
successfully at resolutions from 72 to 1200 dpi in png, jpeg, and tiff 
formats.  I suppose you could use any image format for which there is 
a "pnmto___" program, substituting the appropriate text for the 
format.  The script will look for whatever format you type in there.


Note, if you want a musical example suitable for inserting in a 
word-processed doc or web page, you might want to remove or comment 
out the header block of your file.


Once you've saved and made the file executable (I keep it in my /bin 
directory so it's in my $PATH), just do "lilyimage foobar.ly" and 
enter the resolution and format when prompted.


I copy below the Linux and Mac versions.  It would be cool if someone 
made it work on Windows, to :)


Linux version of "lilyimage" 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

# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff): "
# gather format input
read FORMAT

cd $OUTDIR

# run lilypond on file with png output for further processing...
lilypond --format=png -dresolution=$RES $srcfile

# The next commands crop the png file so that
# it only includes the example instead of an entire page.
# First convert image to pnm for processing with netpbm tools
pngtopnm $STEM.png > $STEM.pnm

# crop all the white space off
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm

# convert to end format
pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT

# removes pnm and ps files
rm *.pnm $STEM.ps

# open final image as background process in "Eye of Gnome" Image Viewer
eog $STEM.$FORMAT &

%%%

Mac version of 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

# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff): "
# gather format input
read FORMAT

cd $OUTDIR

# run lilypond on file with png output for further processing...
/Applications/LilyPond.app/Contents/Resources/bin/lilypond 
--format=png -dresolution=$RES $srcfile


# The next commands crop the png file so that
# it only includes the example instead of an entire page.
# First convert image to pnm for processing with netpbm tools
pngtopnm $STE

Re: png cropping

2008-09-17 Thread Josh Parmenter

You can set the tagline to "" in the \header block.

%% SuperCollider output from Wed Sep 17 12:58:57 2008

\paper {
#(set-paper-size "letter")
}
\include "english.ly"
\header {
tagline = ""
}
%Voice0
soprano = \new Voice = "soprano" {
< c' ef' g'>4
< b f' g'>4
< af bf c' d' e' fs' af' bf'>2
}
\score {
<<
\new Staff = "soprano" <<
\clef treble
\time 4/4
\key c \minor
\soprano
>>
>>
}


Josh

On Sep 17, 2008, at 12:41 PM, Patrick Horgan wrote:


Jonathan Kulp wrote:
This is an old thread but I found it in my email box and thought  
I'd respond because I've recently written a script to handle this  
sort of thing.  I share with some trepidation since last time I  
shared a script, someone pointed out to me that there was already a  
lilypond command-line option that performed exactly the same thing :)
This is wonderful   If there was a way from the lilypond command  
line to suppress a footer that would make it even better.  We  
wouldn't see things like snippet 464 which has a snippet, a huge  
amount of white space, and then a footer.  Of course you can go into  
your favorite editor and crop manually, but if the footer wasn't on  
there, this script could handle it automagically, and instead of  
having to go in and edit the lilypond file to get rid of the footer,  
could just invoke lilypond with the appropriate command line;)


Patrick


Ok so this script requires the "netpbm" package of image  
manipulation programs.  Anyone who builds Lilypond from source  
probably has it already, but it's easy to get under Linux and Mac.   
for Ubuntu I do "sudo apt-get install netpbm" and for mac "sudo  
port install netpbm".  I see that there's a Windows version but  
I've never tried to install that because I rarely use Windows.  So  
far the script works perfectly for Linux and Mac OSX 10.4 (maybe  
10.5 but I can't try it b/c I don't have one).  A couple of lines  
are different in the Mac version because of the different image  
viewer and different way of invoking lilypond at the command line.


What I find useful about the script is that it prompts the user for  
the desired output resolution and format.  So far I've run it  
successfully at resolutions from 72 to 1200 dpi in png, jpeg, and  
tiff formats.  I suppose you could use any image format for which  
there is a "pnmto___" program, substituting the appropriate text  
for the format.  The script will look for whatever format you type  
in there.


Note, if you want a musical example suitable for inserting in a  
word-processed doc or web page, you might want to remove or comment  
out the header block of your file.


Once you've saved and made the file executable (I keep it in my / 
bin directory so it's in my $PATH), just do "lilyimage foobar.ly"  
and enter the resolution and format when prompted.


I copy below the Linux and Mac versions.  It would be cool if  
someone made it work on Windows, to :)


Linux version of "lilyimage" 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

# ask for desired final output format
echo -n "Enter desired output format (jpeg, png, tiff): "
# gather format input
read FORMAT

cd $OUTDIR

# run lilypond on file with png output for further processing...
lilypond --format=png -dresolution=$RES $srcfile

# The next commands crop the png file so that
# it only includes the example instead of an entire page.
# First convert image to pnm for processing with netpbm tools
pngtopnm $STEM.png > $STEM.pnm

# crop all the white space off
pnmcrop -white $STEM.pnm > $STEM-cropped.pnm

# convert to end format
pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT

# removes pnm and ps files
rm *.pnm $STEM.ps

# open final image as background process in "Eye of Gnome" Image  
Viewer

eog $STEM.$FORMAT &

%%%

Mac version of 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

Re: png cropping

2008-09-17 Thread Jonathan Kulp
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.


Re: the footers: are you talking about the "engraving by Lilypond" 
footer or some other thing?  In the examples I've run with this, there 
have been no footers, but I've only been doing my own files.


Jon


Patrick Horgan wrote:

Jonathan Kulp wrote:
This is an old thread but I found it in my email box and thought I'd 
respond because I've recently written a script to handle this sort of 
thing.  I share with some trepidation since last time I shared a 
script, someone pointed out to me that there was already a lilypond 
command-line option that performed exactly the same thing :)


I'd like a version that had an option to change the remaining white 
space to transparent.  I can add the option to the script, do you know 
the command to translate the white space?


Patrick





___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Neil Puttock
Hi Jon,

2008/9/17 Jonathan Kulp <[EMAIL PROTECTED]>:
> 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.

>From the command line: -dpixmap-format=pngalpha

In a .ly file: #(ly:set-option 'pixmap-format "pngalpha")

Regards,
Neil


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Patrick Horgan

Josh Parmenter wrote:

You can set the tagline to "" in the \header block.
Ah, but I specifically asked for a way to do it without editing the file 
so the script to do it via command line argument.  This just doesn't 
make the cut  NEXT!


Patrick



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Patrick Horgan

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 '#ff' 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


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Jonathan Kulp
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 '#ff' $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 '#ff' 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


Re: png cropping

2008-09-17 Thread Jonathan Kulp
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 '#ff' 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 '#ff' $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


Re: png cropping

2008-09-17 Thread Patrick Horgan
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

8< cut here >8~~

#!/bin/bash

#*#

# Script for making image files from lilypond source  #

# suitable for use as musical examples to insert in a #

# document or web page.   #

#*#


getopt_simple()

{

   until [ -z "$1" ] ; do

   if [ ${1:0:1} = '-' ] ; then

   tmp=${1:1}   # Strip off leading '-' . . .

   if [ ${tmp:0:1} = '-' ] ; then

   tmp=${tmp:1} # Allow double -

   fi

   parameter=${tmp%%=*} # Extract name.

   value=${tmp##*=} # Extract value.

   eval $parameter=$value

   else

   filename=$1

   fi

   shift

   done

}


transparency='no'

t='no'

resolution=0

r=0

format='none'

f='none'


getopt_simple $*

if [ $t != 'no' ] ; then

   transparency=$t

fi

if [ $r -ne 0 ] ; then

   resolution=$r

fi

if [ $f != 'none' ] ; then

   format=$f

fi

# get filename from first argument

srcfile="`basename $filename`"


# get filename without .ly extension

STEM="`basename $filename .ly`"


# determine output directory

OUTDIR="`dirname $filename`"


if [[ $resolution -ne 0 ]] ; then

   echo Resolution set to $resolution dots per inch.

   RES=$resolution

else

   # ask for output resolution

   echo -n "Enter output resolution in DPI (72, 100, 300, 600, etc.): "

   # gather resolution input

   read RES

fi


# ask for desired final output format

if [[ $transparency != 'no' ]] ; then

   echo Output format forced to png for transparency

   FORMAT='png'

else

   echo -n "Transparency?y/N "

   #gather transparency

   read TRANSPARENCY

   echo TRANSPARENCY is $TRANSPARENCY

   if [[ ( "$TRANSPARENCY" == "Y" )  || ( "$TRANSPARENCY" == "y" ) ]] ; then

   transparency='yes'

   echo Output format forced to png for transparency

   FORMAT='png'

   else

   if [[ $format != 'none' ]]

   echo Output format is $format

   FORMAT=$format

   else

   echo -n "Enter desired output format (jpeg, png, tiff): "

   # gather format input

   read FORMAT

   fi

   fi

fi


cd $OUTDIR


# run lilypond on file with png output for further processing...

lilypond --format=png -dresolution=$RES $srcfile


# The next commands crop the png file so that

# it only includes the example instead of an entire page.

# First convert image to pnm for processing with netpbm tools

pngtopnm $STEM.png > $STEM.pnm


# crop all the white space off

pnmcrop -white $STEM.pnm > $STEM-cropped.pnm


# convert to end format

if [[ $transparency != 'no' ]] ; then

   pnmto$FORMAT -transparent '#ff' $STEM-cropped.pnm > $STEM.$FORMAT

else

   pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT

fi


# removes pnm and ps files

rm *.pnm $STEM.ps


# open final image as background process in "Eye of Gnome" Image Viewer

eog $STEM.$FORMAT &

fi


cd $OUTDIR


# run lilypond on file with png output for further processing...

lilypond --format=png -dresolution=$RES $srcfile


# The next commands crop the png file so that

# it only includes the example instead of an entire page.

# First convert image to pnm for processing with netpbm tools

pngtopnm $STEM.png > $STEM.pnm


# crop all the white space off

pnmcrop -white $STEM.pnm > $STEM-cropped.pnm


# convert to end format

if [[ $transparency != 'no' ]] ; then

   pnmto$FORMAT -transparent '#ff' $STEM-cropped.pnm > $STEM.$FORMAT

else

   pnmto$FORMAT $STEM-cropped.pnm > $STEM.$FORMAT

fi


# removes pnm and ps files

rm *.pnm $STEM.ps


# open final image as background process in "Eye of Gnome" Image Viewer

eog $STEM.$FORMAT &

fi


cd $OUTDIR


# run lilypond on file with png output for further processing...

lilypond --format=png -dresolution=$RES $srcfile


# The next commands crop the png file so that

# it only includes the example instead of an entire page.

# First convert image to pnm for processing with netpbm tools

pngtopnm $STEM.png > $STEM.pnm


# crop all the white space off

pnmcrop -white $STEM.pnm > $STEM-cropped.pnm


# convert to end format

if [[ $transparency != 'no' ]] ; then

   pnmto$FORMAT -transpare

Re: png cropping

2008-09-17 Thread Patrick Horgan




Neil Puttock wrote:

  Hi Jon,

2008/9/17 Jonathan Kulp <[EMAIL PROTECTED]>:
  
  
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.

  
  
>From the command line: -dpixmap-format=pngalpha

In a .ly file: #(ly:set-option 'pixmap-format "pngalpha")
  

There must be more than this--I don't get any .png file when I use this
option.  Only postscript and pdf.

Patricki

  
Regards,
Neil

  






___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Jonathan Kulp
Sorry, one more adjustment to the script.  I found out that there's no 
ppmtotiff command, so I had to add another conditional to accommodate 
that.  Seems to work with all combinations now:


#!/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 '#ff' $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
  if [ "$FORMAT" == "tiff" ]
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



Patrick Horgan wrote:

Jonathan Kulp wrote:
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 '#ff' to the command line and then 
selecting png so it would work.  It worked like a charm:)


Patrick



--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Neil Puttock
2008/9/18 Patrick Horgan <[EMAIL PROTECTED]>:

> There must be more than this--I don't get any .png file when I use this
> option.  Only postscript and pdf.

You have to use it with --png or -fpng or --format=png.

Regards,
Neil


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-17 Thread Jonathan Kulp
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 '#ff' $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


Re: png cropping

2008-09-17 Thread Jonathan Kulp

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 '#ff' $STEM-cropped.pnm > 
$STEM.$TRANSFORMAT

else
  ppmto$TRANSFORMAT -transparent '#ff' $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


#!/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 "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 '#ff' $STEM-cropped.pnm > 
$STEM.$TRANSFORMAT
else
  ppmto$TRANSFORMAT -transparent '#ff' $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


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-18 Thread Patrick Horgan




Jonathan Kulp wrote:
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 :)
  

Jonathan, on my system there's no ppmtopng or ppmtotiff and ppmtojpeg
is a link to pnmtojpeg.  This is with Hardy Ubuntu and a fresh install
of the utils.  Annoying, no?  It makes the changes to your script break
on my machine.

I've found that creating symbolic links in /usr/bin like:
 ln -s pnmtopng ppmtopng
 ln -s pnmtotiff ppmtotiff
fixes the problem, but why wouldn't that have been done automagically? 
I removed the netpbm package and it didn't remove my links, so they're
really not part of the package.  Maybe I should file a bug against the
package.  It does reinstall the link from ppmtojpeg to pnmtojpeg when I
reinstall it.  How is it set up on your system?

It seems like to be bulletproof, the script needs to check and see
which of ppmto$FORMAT and pnmto$FORMAT exists and use that, that's easy
to do with which, it already has all the code to look through your PATH.

I'm attaching a new version of my version of your script with that
change and a new routine, getval,  that validates input, you use it
like:

 prompt= "Enter desired output format (jpeg, png, tiff, gif, pcx, bmp): "
 goodvals=("jpeg" "png" "tiff" "gif" "pcx" "bmp")
 getval
 FORMAT=$outval

If the user enters something that's not on the goodvals list, for
example joe, it reprompts them after telling them what they might have
entered:

Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  joe
Expecting one of : jpeg  png  tiff  gif  pcx  bmp  
Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  


 Cool, no?  I suppose I should add validation to the command line
arguments as well.
Ok, just did that, resolution checked for numeric both on input and
from the command line, format checked for one of the allowable things,
and check to make sure there's a filename, and print meaningful error
message and a usage statement.  Try it and see if it works for you.
    I'm almost tempted to check for all the pnmto and ppmto and
automatically build the list of allowed types instead of hard coding
them--nah, I'll leave that as an exercise for the reader;)  It really
needs to be done with my version because I only let people use what's
on the list:(  Yours will just work as long as it's a valid format. 
You could grab the outcmd part of my version of your script.  It
automagically picks either ppmto or pnmto and exits with an error if
neither are found.
    I also check for the existence of pnmtojpeg and abort the script if
not found with
a message that the netpbm utilities have to be installed to use the
script.
    Now the script is much larger because of all the checking.

Patrick

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 '#ff' to the command line and then
selecting png so it would work.  It worked like a charm:)


  
  




#!/bin/bash
#*#
# Script for making image files from lilypond source  #
# suitable for use as musical examples to insert in a #
# document or web page.   #
#*#

#~~
# usage is called when we're called incorrectly.
# it never returns
#~~
usage()
{
echo "Usage: " $0 " [-t] [-rN] [-fFORMAT] filename"
echo "  -t  indicates transparency is desired"
echo "  -r=Nset resolution to N (usually 72-2000)"
echo "  -f=FORMAT   set format to FORMAT one of:"
echo "jpeg, png, tiff, gif, pcx, bmp"
echo "  

Re: png cropping

2008-09-18 Thread Jonathan Kulp
Cool, Patrick!  Your scripting skills are admirable!  The only thing 
that worked unlike I expected was when I was asked if I wanted 
transparency, I simply hit "enter," thinking it would default to "no" 
because the N was capitalized, and it prompted me again saying 
"expecting one of these values..."  On my script the enter button worked 
for "no."  Not a big deal.


The way I dealt with the lack of ppmtopng or ppmtotiff was to add 
another "if" statement that called on pnmtopng or pnmtotiff if either 
png or tiff were chosen for the output format.  Probably not very 
elegant or flexible, but the only way I know how to deal with it at the 
moment.  Did you see the latest version? I think you were commenting on 
an earlier version that was broken with png and tiff.  It's hard to keep 
track when I keep posting so many :)


I'm going to study your script carefully when I have more time tonight 
and try it with the command-line options and stuff.  It's shaping up to 
be a very useful tool, at least for me :) Thanks for being so interested 
in it and scripting all these cool features that I don't know how to do.


Jon

(My working version is attached)

Patrick Horgan wrote:

Jonathan Kulp wrote:
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 :)
Jonathan, on my system there's no ppmtopng or ppmtotiff and ppmtojpeg is a link 
to pnmtojpeg.  This is with Hardy Ubuntu and a fresh install of the utils.  
Annoying, no?  It makes the changes to your script break on my machine.


I've found that creating symbolic links in /usr/bin like:

 ln -s pnmtopng ppmtopng

 ln -s pnmtotiff ppmtotiff

fixes the problem, but why wouldn't that have been done automagically?  I 
removed the netpbm package and it didn't remove my links, so they're really not 
part of the package.  Maybe I should file a bug against the package.  It does 
reinstall the link from ppmtojpeg to pnmtojpeg when I reinstall it.  How is it 
set up on your system?


It seems like to be bulletproof, the script needs to check and see which of 
ppmto$FORMAT and pnmto$FORMAT exists and use that, that's easy to do with which, 
it already has all the code to look through your PATH.


I'm attaching a new version of my version of your script with that change and a 
new routine, getval,  that validates input, you use it like:


 prompt= "Enter desired output format (jpeg, png, tiff, gif, pcx, bmp): "

 goodvals=("jpeg" "png" "tiff" "gif" "pcx" "bmp")

 getval

 FORMAT=$outval


If the user enters something that's not on the goodvals list, for example joe, 
it reprompts them after telling them what they might have entered:


Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  joe

Expecting one of : jpeg  png  tiff  gif  pcx  bmp  

Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  


 Cool, no?  I suppose I should add validation to the command line arguments as 
well.
Ok, just did that, resolution checked for numeric both on input and from the 
command line, format checked for one of the allowable things, and check to make 
sure there's a filename, and print meaningful error message and a usage 
statement.  Try it and see if it works for you.
I'm almost tempted to check for all the pnmto and ppmto and automatically 
build the list of allowed types instead of hard coding them--nah, I'll leave 
that as an exercise for the reader;)  It really needs to be done with my version 
because I only let people use what's on the list:(  Yours will just work as long 
as it's a valid format.  You could grab the outcmd part of my version of your 
script.  It automagically picks either ppmto or pnmto and exits with an error if 
neither are found.
I also check for the existence of pnmtojpeg and abort the script if not 
found with

a message that the netpbm utilities have to be installed to use the script.
Now the script is /much/ larger because of all the checking.

Patrick


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 
t

Re: png cropping

2008-09-18 Thread Jonathan Kulp

Hi Patrick,

I've been running your script trying to use the command-line arguments, 
and something's happening with the format argument.  I specify it with 
an argument, but then I still get prompted for format.  I might not be 
doing the flag right.  I've tried it with -f=jpeg, -f=JPEG, -fJPEG, and 
I think that's it.  I'll copy the terminal output below so you can see. 
 On this example I use -fGIF and while it doesn't make the script fail, 
it does still ask me for a format.  Am I specifying the format wrong?


BTW, in the script I attached to the last email, you'll notice that with 
transparent background you have a choice between either png or gif--it's 
not forced to png.  Is there a way to work this option into your version?


Jon

[EMAIL PROTECTED]:~/Documents/Composition/Guitar$ lilytoimage 
dc1-passage.ly -r=300 -fGIF

Resolution set to 300 dots per inch.
Transparency? y/N  n
Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  gif
GNU LilyPond 2.11.59
Processing `dc1-passage.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
Interpreting music...
MIDI output to `dc1-passage.midi'...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `dc1-passage.ps'...
Converting to PNG...
ppmtogif: computing colormap...
ppmtogif: 79 colors found
[EMAIL PROTECTED]:~/Documents/Composition/Guitar$


Patrick Horgan wrote:

Jonathan Kulp wrote:


I'm attaching a new version of my version of your script with that change and a 
new routine, getval,  that validates input, you use it like:


 prompt= "Enter desired output format (jpeg, png, tiff, gif, pcx, bmp): "

 goodvals=("jpeg" "png" "tiff" "gif" "pcx" "bmp")

 getval

 FORMAT=$outval


If the user enters something that's not on the goodvals list, for example joe, 
it reprompts them after telling them what they might have entered:


Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  joe

Expecting one of : jpeg  png  tiff  gif  pcx  bmp  

Enter desired output format (jpeg, png, tiff, gif, pcx, bmp):  


 Cool, no?  I suppose I should add validation to the command line arguments as 
well.
Ok, just did that, resolution checked for numeric both on input and from the 
command line, format checked for one of the allowable things, and check to make 
sure there's a filename, and print meaningful error message and a usage 
statement.  Try it and see if it works for you.

--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-18 Thread Patrick Horgan
   Alright, this is probably my last version.  It now checks the input 
for format against all the available conversions (found by looking for 
all the programs in the filesystem that start with ppmto and pnmto) and 
if you didn't pick one, gives you all the choices! 


Enter desired output format (jpeg, png, tiff, gif, pcx, bmp) ... :  fooburger
Expecting one of : acad  bmp  ddif  eyuv  fiasco  fits  gif  icr  ilbm  jpeg  
leaf  lj  lss16  map
mitsu  mpeg  neo  palm  pcx  pgm  pi1  pict  pj  plainpnm  png  ps  puzz  rast  
rgb3  rle  sgi  sir
sixel  tga  tiff  tiffcmyk  uil  winicon  xpm  xwd  yuv  yuvsplit  
Enter desired output format (jpeg, png, tiff, gif, pcx, bmp) ... :  tiffcmyk



   Of course if you pick one that eog doesn't know how to display it 
will complain.  If you pick one that requires extra command line 
argument, it will complain.  If you comment out the line that removes ps 
and select ps as the format type, then look at the resultant postscript 
file with a postscript viewer, it's rotated 90 degrees!  Cool:)  That 
looks like a bug in pnmtops.  It's a shame that pnmtotiff doesn't have a 
-transparent argument since tiff supports transparency.


   I also fixed a problem where the validation routines would go crazy 
if you just hit enter when prompted for input.  Also made it not prompt 
for transparency if you already specified a format on the command line 
that doesn't support it, and conversely if you asked for transparency on 
the command line and specified a format that doesn't support it, notes 
your user error and asks you to pick gif or png.


   Thanks for inspiring me Jonathan.  I'd like to make clear that all 
of this script that does any useful work is Jonathan's original script.  
My parts just validate input and add command line arguments.  I've 
developed some general purpose routines for this script that I've wished 
to have for a long time and will reuse often.:)


   I can't believe I spent most of my day on this !

Patrick
#!/bin/bash
#*#
# Script for making image files from lilypond source  #
# suitable for use as musical examples to insert in a #
# document or web page.   #
#*#

#~~
# setformatlist - get's the list of all the things that
# you can convert to
#~~
setformatlist()
{
currentdir=`pwd`
examp=`which ppmtojpeg`
echo $examp
if [ $? -eq 0 ] ; then
OUTDIR="`dirname $examp`"
cd $OUTDIR
ppmtos=`ls ppmto* | sed -n s/ppmto//p`
pnmtos=`ls pnmto* | sed -n s/pnmto//p`
alltos=`echo  $ppmtos $pnmtos | tr " " "\n" | sort -u | tr "\n" " "`
fi
cd $currentdir
}
#~~
# usage is called when we're called incorrectly.
# it never returns
#~~
usage()
{
echo "Usage: " $0 " [-t] [-rN] [-fFORMAT] filename"
echo "  -t  indicates transparency is desired"
echo "  -r=Nset resolution to N (usually 72-2000)"
echo "  -f=FORMAT   set format to FORMAT one of:"
echo "jpeg, png, tiff, gif, pcx, bmp"
echo "  filenamea lilypond file"
exit -1
}

#~~
# Set prompt to the prompt you want to give a user
# goodvals to the list of acceptable values
# call getval
# when it returns your value is in outval
#~~
getval()
{
flag="notdone"
[EMAIL PROTECTED]
until [ $flag == "done" ] ; do
echo -n $prompt " "
read inval
if [ A$inval == "A" ] ; then
echo You must enter a value
index=0
echo -n "Expecting one of : "
while [ "$index" -lt "$elementcount" ] ; do
echo -n "${goodvals["$index"]}" " "
let index++
done
echo
else
index=0
while [ "$index" -lt "$elementcount" ] ; do
if [ ${goodvals[$index]} == $inval ] ; then
flag="done"
outval=${goodvals[$index]}
fi
let index++
done
if [ $flag != "done" ] ; then
index=0
echo -n "Expecting one of : "
while [ "$index" -lt "$elementcount" ] ; do
echo -n "${goodvals["$index"]}" " "
let index++
done
echo
fi
fi
done
}

#~~
# Set prompt to the prompt you want to give a user
# call getnumval
# when it returns your value is in outval
#~~
getnumval()
{
flag=

Re: png cropping

2008-09-18 Thread Patrick Horgan

Jonathan Kulp wrote:

Hi Patrick,

I've been running your script trying to use the command-line 
arguments, and something's happening with the format argument.  I 
specify it with an argument, but then I still get prompted for 
format.  I might not be doing the flag right.  I've tried it with 
-f=jpeg, -f=JPEG, -fJPEG, and I think that's it.  I'll copy the 
terminal output below so you can see.  On this example I use -fGIF and 
while it doesn't make the script fail, it does still ask me for a 
format.  Am I specifying the format wrong?
it would have to be the same as the input from the command line, i.e. 
-f=jpeg or -f=gif---I don't have a clue why it would fail, though with 
our weird crossing of versions I don't know which version you're using.  
I put a version in this one, and if you specify -v it will tell you the 
version and quit.  I fixed the defaults as you asked, and put in 
defaults for N 72 and png, (and if they pick transparency a default of 
png as well).  If the command line args still don't work please let me 
know.  They work here. My experience is that whenever I'm sure I've 
tested everything there are still many bugs, so please let me know:)
BTW, in the script I attached to the last email, you'll notice that 
with transparent background you have a choice between either png or 
gif--it's not forced to png. Is there a way to work this option into 
your version?

Yep, fixed.

Patrick
#!/bin/bash
#*#
# Script for making image files from lilypond source  #
# suitable for use as musical examples to insert in a #
# document or web page.   #
#*#

#~~
# setformatlist - get's the list of all the things that
# you can convert to
#~~
setformatlist()
{
currentdir=`pwd`
examp=`which ppmtojpeg`
if [ $? -eq 0 ] ; then
OUTDIR="`dirname $examp`"
cd $OUTDIR
ppmtos=`ls ppmto* | sed -n s/ppmto//p`
pnmtos=`ls pnmto* | sed -n s/pnmto//p`
alltos=`echo  $ppmtos $pnmtos | tr " " "\n" | sort -u | tr "\n" " "`
fi
cd $currentdir
}
#~~
# usage is called when we're called incorrectly.
# it never returns
#~~
usage()
{
echo "Usage: " `basename $0` " [-v] [-t] [-rN] [-fFORMAT] filename"
echo "  -v  print version number and quit"
echo "  -t  indicates transparency is desired"
echo "  -r=Nset resolution to N (usually 72-2000)"
echo "  -f=FORMAT   set format to FORMAT one of:"
echo "jpeg, png, tiff, gif, pcx, bmp"
echo "  filenamea lilypond file"
exit -1
}

#~~
# Set prompt to the prompt you want to give a user
# goodvals to the list of acceptable values
# call getval
# when it returns your value is in outval
#~~
getval()
{
flag="notdone"
[EMAIL PROTECTED]
until [ $flag == "done" ] ; do
echo -n $prompt " "
read inval
if [ A$inval == "A" ] ; then
if [ A$default != 'A' ] ; then
inval=$default
default=""
else
echo You must enter a value
index=0
echo -n "Expecting one of : "
while [ "$index" -lt "$elementcount" ] ; do
echo -n "${goodvals["$index"]}" " "
let index++
done
echo
fi
fi
if [ A$inval != "A" ] ; then
index=0
while [ "$index" -lt "$elementcount" ] ; do
if [ ${goodvals[$index]} == $inval ] ; then
flag="done"
outval=${goodvals[$index]}
fi
let index++
done
if [ $flag != "done" ] ; then
index=0
echo -n "Expecting one of : "
while [ "$index" -lt "$elementcount" ] ; do
echo -n "${goodvals["$index"]}" " "
let index++
done
echo
fi
fi
done
}

#~~
# Set prompt to the prompt you want to give a user
# call getnumval
# when it returns your value is in outval
#~~
getnumval()
{
flag="notdone"
until [ $flag == "done" ] ; do
echo -n $prompt " "
read inval
if [ A$inval == "A" ] ; then
if [ A$default != 'A' ] ; then
inval=$default
default=""
else
echo You must enter a value, expecting a posi

Re: png cropping

2008-09-18 Thread Jonathan Kulp
Patrick!  It's all working beautifully now.  I've tried about 10 
different configurations of options using both the flags and the 
prompts, and everything worked just as expected.  This is a really great 
tool! I like being able to use either the command-line arguments or the 
prompts. The arguments are especially useful if you just want to run 
exactly the same process again after editing the lilypond file, because 
you can just hit the up arrow to get the previous command and not have 
to go through all the prompts again.  I also like the prompts because 
sometimes I forget the command-line options.  But then you've added the 
usage thing, too.  And now a version number 1.1! I never dreamed I'd 
contribute code to something with a version number ;-)


I think we've officially beat this thread to death and now have a nice 
script to show for it.  Thanks for the collaboration!  It's the most fun 
I've had in a while.  Now if I can just get my head around the code you 
wrote I'll be doing something...


Best,

Jonathan

p.s. now that we have a tool with a version number, I might try learning 
how to write a brief manpage for it.  Good idea?


Patrick Horgan wrote:

Jonathan Kulp wrote:

Hi Patrick,

I've been running your script trying to use the command-line 
arguments, and something's happening with the format argument.  I 
specify it with an argument, but then I still get prompted for 
format.  I might not be doing the flag right.  I've tried it with 
-f=jpeg, -f=JPEG, -fJPEG, and I think that's it.  I'll copy the 
terminal output below so you can see.  On this example I use -fGIF and 
while it doesn't make the script fail, it does still ask me for a 
format.  Am I specifying the format wrong?
it would have to be the same as the input from the command line, i.e. 
-f=jpeg or -f=gif---I don't have a clue why it would fail, though with 
our weird crossing of versions I don't know which version you're using.  
I put a version in this one, and if you specify -v it will tell you the 
version and quit.  I fixed the defaults as you asked, and put in 
defaults for N 72 and png, (and if they pick transparency a default of 
png as well).  If the command line args still don't work please let me 
know.  They work here. My experience is that whenever I'm sure I've 
tested everything there are still many bugs, so please let me know:)
BTW, in the script I attached to the last email, you'll notice that 
with transparent background you have a choice between either png or 
gif--it's not forced to png. Is there a way to work this option into 
your version?

Yep, fixed.

Patrick



--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Mark Knoop
On Thu, 2008-09-18 at 17:41 -0700, Patrick Horgan wrote:
> Of course if you pick one that eog doesn't know how to display it 
> will complain. 

Perhaps replace eog with xdg-open for better portability?

"xdg-open - opens a file or URL in the user’s preferred application"


-- 
Mark Knoop


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Jonathan Kulp
This is a good idea.  I tried it and it behaves exactly the same as 
before.  I had wondered about this, not with respect to the different 
file formats, but with different desktop environments.  I imagine eog 
wouldn't behave properly in KDE, for example.  Does xdg-open work for 
KDE?  Or does that little g stand for gnome still?  The next thing I 
want to do with the script is make it check to see whether the user is 
running Linux or Mac OSX and execute the proper command.  I should also 
make a condition for different desktop environments I guess.  Thanks,


Jon

Mark Knoop wrote:

On Thu, 2008-09-18 at 17:41 -0700, Patrick Horgan wrote:
Of course if you pick one that eog doesn't know how to display it 
will complain. 


Perhaps replace eog with xdg-open for better portability?

"xdg-open - opens a file or URL in the user’s preferred application"




--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Patrick Horgan




Jonathan Kulp wrote:
Patrick! 
It's all working beautifully now. 

I must say that you are most awesomely cool.  How wonderful to find
someone that digs in in the best linux/Unix tradition and puts together
a string of programs to achieve a desired result.  Hats off to you.

... much cool stuff elided...
p.s. now
that we have a tool with a version number, I might try learning how to
write a brief manpage for it.  Good idea?
A most excellent idea!  manedit is your friend.  Complete wysiwyg man
editor.  Its help has a complete and easy tutorial.  On ubuntu it's
just sudo apt-get install manedit.  Since
you're doing that I'm adding a -a (about) with your name and mine, some
more comments so others can modify it more easily, and will call it
version 1.1.1.  I also added a -V=viewer, so I could use, for example
evince if the output format was ps.  N.B. evince doesn't display
transparency so if you use it with transparent gifs or pngs you might
think the transparency gone, but it's not. 

    One feature it really needs is an ability to handle the situation
where the output for file.ly is for example, file-page1.png and
file-page2.png.  You'd have to get a wildcard list of things that
matched $STEM*.png and loop over them to do the conversions, then
something like $viewer $STEM*.$FORMAT & at the end.  That would
make it work as it currently does for most things, there'd just be one
thing in the list, but still work for the case where there's something
there.  A generic wildcard is best because someone might have done a
#(define output-suffix "blablabla") and we want to support that case
too.  eog will bring up all the pages and let you page up and page down
through them, and evince will bring a a window for each file.  There's
enough examples in the script so that you could figure out how to do it
if you would.  We could call it 1.1.2;)  If you don't have time let me
know and I'll get to it sometime.  If you do, change the version in the
script, add to the changelog at the top and send me a copy:)  Maybe we
could donate it to the lilypond project.

Patrick


#!/bin/bash
#*#
# Script for making image files from lilypond source  #
# suitable for use as musical examples to insert in a #
# document or web page.   #
# Creator  - Jonathan Kulp#
# Johnny come lately assistant - Patrick Horgan   #
#*#
# Change log
#
# 1.1.1 Added -a, -V and much comments
# 1.1   Added checking of return codes so we could
#   abort if something failed.
# 1.0   Initial release
#~~
# setformatlist - gets the list of all the things that
# you can convert to
#~~
setformatlist()
{
currentdir=`pwd`# Remember our current directory
examp=`which ppmtojpeg` # find out where the progs are
returnstatus=$?
if [ $returnstatus -eq 0 ] ; then
OUTDIR="`dirname $examp`" #grab the directory
cd $OUTDIR  # change to it so we can
# find all the programs starting with ppmto
# and remove the initial part so that we can 
# figure out what ppms can be converted to
ppmtos=`ls ppmto* | sed -n s/ppmto//p`
# same for pnmto
pnmtos=`ls pnmto* | sed -n s/pnmto//p`
# Now combine the two, change the space separated
# list into individ line that sort can sort with
# -u to throw away duplicates, then change newlines
# back to spaces so we have a sorted list without
# duplicate of all things we can convert to
alltos=`echo  $ppmtos $pnmtos | tr " " "\n" | sort -u | tr "\n" " "`
fi
cd $currentdir   # Change back so we don't affect anything
}
#~~
# usage is called when we're called incorrectly.
# it never returns
#~~
usage()
{
echo "Usage: " `basename $0` " [-v] [-t] [-rN] [-fFORMAT] filename"
echo "  -v  print version number and quit"
echo "  -a  about - tell about us and exit"
echo "  -t  indicates transparency is desired"
echo "  -r=Nset resolution to N (usually 72-2000)"
echo "  -f=FORMAT   set format to FORMAT one of:"
echo "jpeg, png, tiff, gif, pcx, bmp"
echo "  -V=viewer   set image viewer, examp: -V=evince"
echo "  filenamea lilypond file"
exit -1
}

#~~
# about - tell about us and exit
#~~
about()
{
echo `basename $0`
echo "  Creator Jonathan Kulp"
echo "  Johnny-come-lately  Patrick Horgan"
exit 0
}

#~~

Re: png cropping

2008-09-19 Thread Patrick Horgan




Mark Knoop wrote:

  On Thu, 2008-09-18 at 17:41 -0700, Patrick Horgan wrote:
  
  
Of course if you pick one that eog doesn't know how to display it 
will complain. 

  
  
Perhaps replace eog with xdg-open for better portability?

"xdg-open - opens a file or URL in the user’s preferred application"
  

I didn't know about that:)  I just tried it with -V=xdg-open with a ps
output and a png output and it used evince and eog respectively
automagically;)  I changed it so that it sets its default viewer
dynamically from a list, looking for xdg-open, and if not found, eog,
and if not found evince, and if still not found, at the end politely
tells you that it didn't find a viewer and is only generating output. 
That makes 1.1.1.1 a very minor release since it didn't change anything
visible to the user;)

Patrick

  

  




#!/bin/bash
#*#
# Script for making image files from lilypond source  #
# suitable for use as musical examples to insert in a #
# document or web page.   #
# Creator  - Jonathan Kulp#
# Johnny come lately assistant - Patrick Horgan   #
#*#
# Change log
#
# 1.1.1.1   Added search for default list of viewers
# 1.1.1 Added -a, -V and much comments changed default
#   viewer to xdg-open
# 1.1   Added checking of return codes so we could
#   abort if something failed.
# 1.0   Initial release
#~~
# setformatlist - gets the list of all the things that
# you can convert to
#~~
setformatlist()
{
currentdir=`pwd`# Remember our current directory
examp=`which ppmtojpeg` # find out where the progs are
returnstatus=$?
if [ $returnstatus -eq 0 ] ; then
OUTDIR="`dirname $examp`" #grab the directory
cd $OUTDIR  # change to it so we can
# find all the programs starting with ppmto
# and remove the initial part so that we can 
# figure out what ppms can be converted to
ppmtos=`ls ppmto* | sed -n s/ppmto//p`
# same for pnmto
pnmtos=`ls pnmto* | sed -n s/pnmto//p`
# Now combine the two, change the space separated
# list into individ line that sort can sort with
# -u to throw away duplicates, then change newlines
# back to spaces so we have a sorted list without
# duplicate of all things we can convert to
alltos=`echo  $ppmtos $pnmtos | tr " " "\n" | sort -u | tr "\n" " "`
fi
cd $currentdir   # Change back so we don't affect anything
}
#~~
# usage is called when we're called incorrectly.
# it never returns
#~~
usage()
{
echo "Usage: " `basename $0` " [-v] [-t] [-rN] [-fFORMAT] filename"
echo "  -v  print version number and quit"
echo "  -a  about - tell about us and exit"
echo "  -t  indicates transparency is desired"
echo "  -r=Nset resolution to N (usually 72-2000)"
echo "  -f=FORMAT   set format to FORMAT one of:"
echo "jpeg, png, tiff, gif, pcx, bmp"
echo "  -V=viewer   set image viewer, examp: -V=evince"
echo "  filenamea lilypond file"
exit -1
}

#~~
# about - tell about us and exit
#~~
about()
{
echo `basename $0`
echo "  Creator Jonathan Kulp"
echo "  Johnny-come-lately  Patrick Horgan"
exit 0
}

#~~
# Set prompt to the prompt you want to give a user
# goodvals to the list of acceptable values
# call getval
# when it returns your value is in outval
#~~
getval()
{
flag="notdone"
[EMAIL PROTECTED]
until [ $flag == "done" ] ; do
echo -n $prompt " "
read inval
if [ A$inval == "A" ] ; then
# inval is empty
if [ A$default != 'A' ] ; then
# default is set to something
inval=$default
default=""
else
#inval is empty, no default
echo You must enter a value
index=0
echo -n "Expecting one of : "
while [ "$index" -lt "$elementcount" ] ; do
echo -n "${goodvals["$index"]}" " "
let index++
done
echo
fi
fi
if [ A$inval != "A" ] ; then
# inval not empty, either they sent us something
# or we got it from the default
index=0
while 

Re: png cropping

2008-09-19 Thread Jonathan Kulp
Ok I've caught on to your version-control comments at the top and have 
started adding to them.  This time I added two things to the script:


1) recognition of the computer's OS (only Linux or Mac at this point), 
and appropriate changes to the commands to accommodate.  After this 
change, the script works exactly the same (from user's perspective) on 
both my Ubuntu and Mac OSX 10.4 systems :)  I used to have to keep 
separate versions of the script for each one.


2) added a "known issue" comment that the script doesn't handle spaces 
in directory names.  It fails at line 43 (cd $currentdir) if the 
directory of the lilypond source file has a space in the name.


Patrick Horgan wrote:

Jonathan Kulp wrote:

Patrick!  It's all working beautifully now.
I must say that you are most awesomely cool.  How wonderful to find someone that 
digs in in the best linux/Unix tradition and puts together a string of programs 
to achieve a desired result.  Hats off to you.


Working on this script is making me understand the genius of the Unix 
model.  Someone with no programming experience like me can make 
something that gets a job done using a bunch of tiny tools.  Really fun!



... much cool stuff elided...
p.s. now that we have a tool with a version number, I might try learning how 
to write a brief manpage for it.  Good idea?
A most excellent idea!  manedit is your friend.  Complete wysiwyg man editor.  
Its help has a complete and easy tutorial.  On ubuntu it's just *sudo apt-get 
install manedit*.  Since you're doing that I'm adding a -a (about) with your 
name and mine, some more comments so others can modify it more easily, and will 
call it version 1.1.1.  I also added a -V=viewer, so I could use, for example 
evince if the output format was ps.  N.B. evince doesn't display transparency so 
if you use it with transparent gifs or pngs you might think the transparency 
gone, but it's not.



Cool.  I'll try this after the kids are in bed tonight.

One feature it really needs is an ability to handle the situation where the 
output for file.ly is for example, file-page1.png and file-page2.png.  You'd 
have to get a wildcard list of things that matched $STEM*.png and loop over them 
to do the conversions, then something like $viewer $STEM*.$FORMAT & at the end.  
That would make it work as it currently does for most things, there'd just be 
one thing in the list, but still work for the case where there's something 
there.  A generic wildcard is best because someone might have done a #(define 
output-suffix "blablabla") and we want to support that case too.  eog will bring 
up all the pages and let you page up and page down through them, and evince will 
bring a a window for each file.  There's enough examples in the script so that 
you could figure out how to do it if you would.  We could call it 1.1.2;)  If 
you don't have time let me know and I'll get to it sometime.  If you do, change 
the version in the script, add to the changelog at the top and send me a copy:)  
Maybe we could donate it to the lilypond project.


Patrick

Yes.  I haven't thought much about multiple-page documents yet because 
for me the object of the script is to produce small images of musical 
examples to use in a research paper or on a website.  Are there 
situations where you want multiple-page examples with whitespace cropped 
like this?  I could see where it'd be nice to make a longer document's 
background transparent.  It's certainly worth a try to deal with a 
longer file.  The more flexible the script is, the better, after all. 
I'll poke around with it this weekend, perhaps.


Most recent version attached.

Jon

--
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.   #
# Creator  - Jonathan Kulp#
# Johnny come lately assistant - Patrick Horgan   #
#*#
# Change log
#
# 1.1.2 Added platform recognition--Darwin or Linux
#   Known issue: does not handle spaces in directory names
# 1.1.1 Added -a, -V and much comments
# 1.1   Added checking of return codes so we could
#   abort if something failed.
# 1.0   Initial release
# 
#~~
# setformatlist - gets the list of all the things that
# you can convert to
#~~
setformatlist()
{
currentdir=`pwd`# Remember our current directory
examp=`which ppmtojpeg` # find out where the progs are
returnstatus=$?
if [ $returnstatus -eq 0 ] ; then
OUTDIR="`dirname $examp`" #grab the directory
cd $OUTDIR  # change to it so we can
# find all the programs starting with ppmto
# and remove the initial part so that we can 
# figu

Re: png cropping

2008-09-19 Thread Josh Parmenter
I've been following this, and just tested the latest version on OSX...  
quite nice guys!


Perhaps the -V flag can be set to not open the image after it is done?  
This utility will be great for mass creating images (as most command  
line tools are), but having Preview open each one up will get very  
tiring... perhaps if the is no -V passed in, that step can be skipped?


Again - quite nice!

Josh

On Sep 19, 2008, at 2:20 PM, Jonathan Kulp wrote:

Ok I've caught on to your version-control comments at the top and  
have started adding to them.  This time I added two things to the  
script:


1) recognition of the computer's OS (only Linux or Mac at this  
point), and appropriate changes to the commands to accommodate.   
After this change, the script works exactly the same (from user's  
perspective) on both my Ubuntu and Mac OSX 10.4 systems :)  I used  
to have to keep separate versions of the script for each one.


2) added a "known issue" comment that the script doesn't handle  
spaces in directory names.  It fails at line 43 (cd $currentdir) if  
the directory of the lilypond source file has a space in the name.


Patrick Horgan wrote:

Jonathan Kulp wrote:

Patrick!  It's all working beautifully now.
I must say that you are most awesomely cool.  How wonderful to find  
someone that digs in in the best linux/Unix tradition and puts  
together a string of programs to achieve a desired result.  Hats  
off to you.
Working on this script is making me understand the genius of the  
Unix model.  Someone with no programming experience like me can make  
something that gets a job done using a bunch of tiny tools.  Really  
fun!



... much cool stuff elided...
p.s. now that we have a tool with a version number, I might try  
learning how to write a brief manpage for it.  Good idea?
A most excellent idea!  manedit is your friend.  Complete wysiwyg  
man editor.  Its help has a complete and easy tutorial.  On ubuntu  
it's just *sudo apt-get install manedit*.  Since you're doing that  
I'm adding a -a (about) with your name and mine, some more comments  
so others can modify it more easily, and will call it version  
1.1.1.  I also added a -V=viewer, so I could use, for example  
evince if the output format was ps.  N.B. evince doesn't display  
transparency so if you use it with transparent gifs or pngs you  
might think the transparency gone, but it's not.

Cool.  I'll try this after the kids are in bed tonight.

   One feature it really needs is an ability to handle the  
situation where the output for file.ly is for example, file- 
page1.png and file-page2.png.  You'd have to get a wildcard list of  
things that matched $STEM*.png and loop over them to do the  
conversions, then something like $viewer $STEM*.$FORMAT & at the  
end.  That would make it work as it currently does for most things,  
there'd just be one thing in the list, but still work for the case  
where there's something there.  A generic wildcard is best because  
someone might have done a #(define output-suffix "blablabla") and  
we want to support that case too.  eog will bring up all the pages  
and let you page up and page down through them, and evince will  
bring a a window for each file.  There's enough examples in the  
script so that you could figure out how to do it if you would.  We  
could call it 1.1.2;)  If you don't have time let me know and I'll  
get to it sometime.  If you do, change the version in the script,  
add to the changelog at the top and send me a copy:)  Maybe we  
could donate it to the lilypond project.

Patrick
Yes.  I haven't thought much about multiple-page documents yet  
because for me the object of the script is to produce small images  
of musical examples to use in a research paper or on a website.  Are  
there situations where you want multiple-page examples with  
whitespace cropped like this?  I could see where it'd be nice to  
make a longer document's background transparent.  It's certainly  
worth a try to deal with a longer file.  The more flexible the  
script is, the better, after all. I'll poke around with it this  
weekend, perhaps.


Most recent version attached.

Jon

--
Jonathan Kulp
http://www.jonathankulp.com
___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


**
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own  
interpretation of how modern society is structured: whether actively  
or passively, consciously or unconsciously, he makes choices in this  
regard. He may be conservative or he may subject himself to continual  
renewal; or he may strive for a revolutionary, historical or social  
palingenesis." - Luigi Nono

*/



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Patrick Horgan

Josh Parmenter wrote:
I've been following this, and just tested the latest version on OSX... 
quite nice guys!


Perhaps the -V flag can be set to not open the image after it is done? 
This utility will be great for mass creating images (as most command 
line tools are), but having Preview open each one up will get very 
tiring... perhaps if the is no -V passed in, that step can be skipped?

If you enter -V="" then it will do that. (or just -V= )

Patrick


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Jonathan Kulp
Thanks for trying it out, Josh!  Glad to hear it worked for you on OSX. 
  Patrick has been dealing with the flags, and I don't really 
understand how to do them, so my very dirty solution would be simply to 
comment out the last bit of the script that opens the file :).  I can 
see how this would be tiresome if you were running it on a bunch of files.


Jon

Josh Parmenter wrote:
I've been following this, and just tested the latest version on OSX... 
quite nice guys!


Perhaps the -V flag can be set to not open the image after it is done? 
This utility will be great for mass creating images (as most command 
line tools are), but having Preview open each one up will get very 
tiring... perhaps if the is no -V passed in, that step can be skipped?


Again - quite nice!

Josh


--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Josh Parmenter
Not on OSX. You are using the 'open' command, and this will open the  
file regardless of the viewer that is passed in.


Josh

On Sep 19, 2008, at 2:51 PM, Patrick Horgan wrote:


Josh Parmenter wrote:
I've been following this, and just tested the latest version on  
OSX... quite nice guys!


Perhaps the -V flag can be set to not open the image after it is  
done? This utility will be great for mass creating images (as most  
command line tools are), but having Preview open each one up will  
get very tiring... perhaps if the is no -V passed in, that step can  
be skipped?

If you enter -V="" then it will do that. (or just -V= )

Patrick


**
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own  
interpretation of how modern society is structured: whether actively  
or passively, consciously or unconsciously, he makes choices in this  
regard. He may be conservative or he may subject himself to continual  
renewal; or he may strive for a revolutionary, historical or social  
palingenesis." - Luigi Nono

*/



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Patrick Horgan

Jonathan Kulp wrote:
Thanks for trying it out, Josh!  Glad to hear it worked for you on 
OSX.   Patrick has been dealing with the flags, and I don't really 
understand how to do them, so my very dirty solution would be simply 
to comment out the last bit of the script that opens the file :).  I 
can see how this would be tiresome if you were running it on a bunch 
of files.
It would be cool to have a -q (quiet) mode that didn't have any output, 
just quietly did it's work, and never popped up a viewer.  Of course it 
would return a status to tell you if it was successful.


Patrick


Jon

Josh Parmenter wrote:
I've been following this, and just tested the latest version on 
OSX... quite nice guys!


Perhaps the -V flag can be set to not open the image after it is 
done? This utility will be great for mass creating images (as most 
command line tools are), but having Preview open each one up will get 
very tiring... perhaps if the is no -V passed in, that step can be 
skipped?


Again - quite nice!

Josh





___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Josh Parmenter

That makes sense as well.

Josh

On Sep 19, 2008, at 3:09 PM, Patrick Horgan wrote:


Jonathan Kulp wrote:
Thanks for trying it out, Josh!  Glad to hear it worked for you on  
OSX.   Patrick has been dealing with the flags, and I don't really  
understand how to do them, so my very dirty solution would be  
simply to comment out the last bit of the script that opens the  
file :).  I can see how this would be tiresome if you were running  
it on a bunch of files.
It would be cool to have a -q (quiet) mode that didn't have any  
output, just quietly did it's work, and never popped up a viewer.   
Of course it would return a status to tell you if it was successful.


Patrick


Jon

Josh Parmenter wrote:
I've been following this, and just tested the latest version on  
OSX... quite nice guys!


Perhaps the -V flag can be set to not open the image after it is  
done? This utility will be great for mass creating images (as most  
command line tools are), but having Preview open each one up will  
get very tiring... perhaps if the is no -V passed in, that step  
can be skipped?


Again - quite nice!

Josh





**
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own  
interpretation of how modern society is structured: whether actively  
or passively, consciously or unconsciously, he makes choices in this  
regard. He may be conservative or he may subject himself to continual  
renewal; or he may strive for a revolutionary, historical or social  
palingenesis." - Luigi Nono

*/



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-09-19 Thread Jonathan Kulp
I'd like to try to implement the -q quiet mode and see if I can do it. I 
think with all of Patrick's flags I can see how he's been doing it and 
make the -q work. Hopefully tonight after the kids are asleep.


Jon

Josh Parmenter wrote:

That makes sense as well.

Josh

On Sep 19, 2008, at 3:09 PM, Patrick Horgan wrote:

It would be cool to have a -q (quiet) mode that didn't have any 
output, just quietly did it's work, and never popped up a viewer.  Of 
course it would return a status to tell you if it was successful.


Patrick


Jon

Josh Parmenter wrote:
I've been following this, and just tested the latest version on 
OSX... quite nice guys!


Perhaps the -V flag can be set to not open the image after it is 
done? This utility will be great for mass creating images (as most 
command line tools are), but having Preview open each one up will 
get very tiring... perhaps if the is no -V passed in, that step can 
be skipped?


Again - quite nice!

Josh





**
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own 
interpretation of how modern society is structured: whether actively or 
passively, consciously or unconsciously, he makes choices in this 
regard. He may be conservative or he may subject himself to continual 
renewal; or he may strive for a revolutionary, historical or social 
palingenesis." - Luigi Nono

*/




--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-01 Thread Jonathan Kulp
After much revision, addition, and general fussing about with it, I'm 
happy to post the official version of what we're calling "lily2image," a 
 script for converting lilypond source files to cropped image files in 
many different formats suitable for insertion into documents (theses, 
research papers, etc) or web pages.  This works equally on Mac and 
Linux, but not on Windows.  Dependency: netpbm (available in Linux repos 
and MacPorts)


Many, many thanks to Patrick Horgan for all of his work on this.  He 
added tons of code and gave me excellent guidance as I was learning how 
to script.  This was a great learning experience.


Thanks also to Josh Parmenter, who jumped in somewhere along the way and 
made very helpful suggestions, and also tested every revision I sent 
him.  Thanks for a fun project, guys!  I hope others in the Lilypond 
community will find it a useful tool.


Jon

p.s. I've also attached my manpage for the script: lily2image.1.  Just 
put it somewhere in your manpath and make sure it has read permissions 
for all users.  I put it here on Linux:


/usr/share/man/man1/lily2image.1

It was slightly different on Mac but now I can't remember.  If someone 
needs help I'll check on it.

--
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.#
# Creator   - Jonathan Kulp#
# Scripting Guru- Patrick Horgan   #
#**#
# Change log
#
# 1.2   Added loop to image conversion to accommodate lilypond files that 
#   have more than one page. It loops until it has converted each of 
the 
#   png files output by Lilypond.  
# 1.1.1.12  Added final exit 0 status at end of file; updated manpage
# 1.1.1.11  Added jpg=jpeg, tif=tiff when values set at command line; added
#   echoes of netpbm activity and echoes at end of process.
# 1.1.1.10  -V implies -p ph
# 1.1.1.9   Added range check to getnumval ph
# 1.1.1.8   -p flag is now necessary for preview--image is not opened in 
#   viewer by default. jk
#   Quiet mode is really quiet as long as sufficient parameters are
#   set at command line for process to succeed. jk
# 1.1.1.7   Added -p flag: allows forced preview even in quiet mode. jk
#   Made quiet mode more quiet. jk
# 1.1.1.6   Changed the call to Lilypond on OSX by defining $PATH
#   early in the script. Changed Patrick's "Johnny Come Lately" to
#   "Major Contributor" :) and added a few echoes when formats,
#   resolutions, and so forth are set. We could remove these if you 
#   they're too much. jk
# 1.1.1.5   Added -w option to specify white background and avoid prompt for
#   transparency jk
# 1.1.1.4   Added lines to clean up png file if desired format is not png. jk
# 1.1.1.3   Changed list of Darwin viewers--Darwin doesn't have eog and evince
#   Added quiet mode "-q" (I think it works!) jk
# 1.1.1.2   Fixed handling of dirs and files with spaces ph
# 1.1.1.1   Added search for default list of viewers ph
# 1.1.1 Added -a, -V and much comments changed default viewer to xdg-open ph
# 1.1   Added checking of return codes so we could
#   abort if something failed. ph
# 1.0   Initial beta release jk
#~~~
# in quiet mode exits with various return codes from
# failures
# 40 - transparency not set and no default
# 41 - format not set and no default
# 42 - resolution not set and no default
# 43 - netpbm utilities not installed
# 44 - unable to find conversion program for desired output
# 45 - resolution from command line not positive numeric
# 46 - format from command line invalid
# various - if any of the programs we call fail, we
#   exit with whatever error code they returned
#~~~
# setformatlist - gets the list of all the things that # you can convert to
#~~~
setformatlist()
{
currentdir=`pwd`# Remember our current directory
examp=`which ppmtojpeg` # find out where the progs are
returnstatus=$?
if [ $returnstatus -eq 0 ] ; then
# We found it! Use it as model to find the rest.
OUTDIR="`dirname $examp`" #grab the directory
cd $OUTDIR  # change to it so we can
# find all the programs starting with ppmto
# and remove the initial part so that we can 
# figure out what ppms can be converted to
ppmtos=`ls ppmto* | sed -n s/ppmto//p`
# same for pnmto
  

Re: png cropping

2008-10-02 Thread Tomas Valusek



Jonathan Kulp napsal(a):
After much revision, addition, and general fussing about with it, I'm 
happy to post the official version of what we're calling "lily2image," a 
 script for converting lilypond source files to cropped image files in 
many different formats suitable for insertion into documents (theses, 
research papers, etc) or web pages.  This works equally on Mac and 
Linux, but not on Windows. 


Not on Windows :-( ... Just great :-(

TomV




___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-02 Thread Josh Parmenter
If you are familiar with scripting, and have Windows, use it as a  
template. But my guess is you will need to find different utilities to  
do the conversion and cropping. This is pretty straight-forward to do,  
since most of these utilities run just fine on linux and mac (though  
most scripts check for the system that is running, and make  
adjustments as needed). The hard work I would say is done (great job  
Jonathan and Patrick!). There is no reason you couldn't use this  
script as a template and make something similar for Windows. I know  
Jonathan used this project as an impetus to learn how to script...  
rather then just complaining, perhaps you can do the same.


Best,

Josh

On Oct 2, 2008, at 12:21 PM, Tomas Valusek wrote:




Jonathan Kulp napsal(a):
After much revision, addition, and general fussing about with it,  
I'm happy to post the official version of what we're calling  
"lily2image," a  script for converting lilypond source files to  
cropped image files in many different formats suitable for  
insertion into documents (theses, research papers, etc) or web  
pages.  This works equally on Mac and Linux, but not on Windows.


Not on Windows :-( ... Just great :-(

TomV




___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


**
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/

“Every composer – at all times and in all cases – gives his own  
interpretation of how modern society is structured: whether actively  
or passively, consciously or unconsciously, he makes choices in this  
regard. He may be conservative or he may subject himself to continual  
renewal; or he may strive for a revolutionary, historical or social  
palingenesis." - Luigi Nono

*/



___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-02 Thread Jonathan Kulp
If you have the skills to translate it to Windows that'd be great.  I 
don't know the first thing about Windows so I can't do it myself.  I'd 
really appreciate it if someone could make a Windows version of 
lily2image :)


Jon

Tomas Valusek wrote:



Jonathan Kulp napsal(a):
After much revision, addition, and general fussing about with it, I'm 
happy to post the official version of what we're calling "lily2image," 
a  script for converting lilypond source files to cropped image files 
in many different formats suitable for insertion into documents 
(theses, research papers, etc) or web pages.  This works equally on 
Mac and Linux, but not on Windows. 


Not on Windows :-( ... Just great :-(

TomV




___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user



--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-02 Thread Patrick Horgan

Tomas Valusek wrote:



Jonathan Kulp napsal(a):
After much revision, addition, and general fussing about with it, I'm 
happy to post the official version of what we're calling 
"lily2image," a  script for converting lilypond source files to 
cropped image files in many different formats suitable for insertion 
into documents (theses, research papers, etc) or web pages.  This 
works equally on Mac and Linux, but not on Windows.
Well, not 100% true.  I imagine if you set up the cygwin stuff (or one 
of the standalone Windoze bash implementations, and got all the netpbm 
utilites installed it would work.  It would be great if someone could 
verify that.   It's just a script, not an executable.


Patrick


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-02 Thread Jonathan Kulp
I've actually tried to do this.  I booted into the Windows partition of 
my machine and installed Cygwin and the netpbm package, but I had 
trouble finding the netpbm stuff from the Cygwin bash shell.  The shell 
seemed very isolated from the rest of the machine, as I couldn't access 
any of the documents in my home directory and in general it behaved in 
much the same way that virtual machines do when I've tried running them. 
 I couldn't even figure out how to run Lilypond from the Cygwin prompt, 
and the script pretty much relies on being able to do that :)


There's probably a way to make it work, but I didn't see the point since 
everything already worked perfectly on the Unix-based systems, which are 
the only ones I use.  It would take someone who really knows Windows to 
adapt lily2image to work on it.  I would welcome it because I think it's 
an extremely useful tool and it's a shame that Windows users can't take 
advantage of it.


Patrick, you mentioned at some point along the way that it would have 
been better if I had started the whole thing in Python instead of bash. 
 Would this also have made it easier to port to Windows?  I've ordered 
a Python book and will probably start messing around with it when it 
gets here.


Jon

Patrick Horgan wrote:

Tomas Valusek wrote:



Jonathan Kulp napsal(a):
After much revision, addition, and general fussing about with it, I'm 
happy to post the official version of what we're calling 
"lily2image," a  script for converting lilypond source files to 
cropped image files in many different formats suitable for insertion 
into documents (theses, research papers, etc) or web pages.  This 
works equally on Mac and Linux, but not on Windows.
Well, not 100% true.  I imagine if you set up the cygwin stuff (or one 
of the standalone Windoze bash implementations, and got all the netpbm 
utilites installed it would work.  It would be great if someone could 
verify that.   It's just a script, not an executable.


Patrick


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user



--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-03 Thread Francisco Vila
2008/10/3 Jonathan Kulp <[EMAIL PROTECTED]>:
> Patrick, you mentioned at some point along the way that it would have been
> better if I had started the whole thing in Python instead of bash.  Would
> this also have made it easier to port to Windows?

IMO yes, as for the script itself, and no, as for the tools it uses,
that are external anyway.
-- 
Francisco Vila. Badajoz (Spain)
http://www.paconet.org


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-03 Thread Patrick Horgan

Jonathan Kulp wrote:
I've actually tried to do this.  I booted into the Windows partition 
of my machine and installed Cygwin and the netpbm package, but I had 
trouble finding the netpbm stuff from the Cygwin bash shell.  The 
shell seemed very isolated from the rest of the machine, as I couldn't 
access any of the documents in my home directory and in general it 
behaved in much the same way that virtual machines do when I've tried 
running them.  I couldn't even figure out how to run Lilypond from the 
Cygwin prompt, and the script pretty much relies on being able to do 
that :)
It's that pesky PATH thing again:)   If you have the stuff on there, and 
a PATH variable that points to the various places, then it will work.


Patrick


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-03 Thread Patrick Horgan

Francisco Vila wrote:

2008/10/3 Jonathan Kulp <[EMAIL PROTECTED]>:
  

Patrick, you mentioned at some point along the way that it would have been
better if I had started the whole thing in Python instead of bash.  Would
this also have made it easier to port to Windows?

It wouldn't make it any easier or harder.  If you used Python you'd have 
to have the PATH set up and you'd have to have python.  It's just the 
script would have been much easier.


Patrick


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: png cropping

2008-10-03 Thread Jonathan Kulp
Yes, that would probably do it.  I'll see if I can sort any of it out 
tonight after the kids are in bed.  Thanks for the suggestion, as 
always, Patrick. :)


Jon

Patrick Horgan wrote:

Jonathan Kulp wrote:
I've actually tried to do this.  I booted into the Windows partition 
of my machine and installed Cygwin and the netpbm package, but I had 
trouble finding the netpbm stuff from the Cygwin bash shell.  The 
shell seemed very isolated from the rest of the machine, as I couldn't 
access any of the documents in my home directory and in general it 
behaved in much the same way that virtual machines do when I've tried 
running them.  I couldn't even figure out how to run Lilypond from the 
Cygwin prompt, and the script pretty much relies on being able to do 
that :)
It's that pesky PATH thing again:)   If you have the stuff on there, and 
a PATH variable that points to the various places, then it will work.


Patrick



--
Jonathan Kulp
http://www.jonathankulp.com


___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-24 Thread Andrew Bernard
HI Renato,

As an aside, why would you use backend = eps if you are generating a PNG
file? I think you can omit that.

Andrew
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread Klaus Blum
Hi Renato, hi Andrew,

Andrew Bernard wrote
> why would you use backend = eps if you are generating a PNG file? I think
> you can omit that.

The auto-cropping features only work with the EPS backend which can also be
used to generate PNG or PDF output. 
Making use of 
\include "lilypond-book-preamble.ly"
has the same effect.


Renato-23 wrote
> How can I produce a png with some nonzero margins? I've tried to add
> top-margin, bottom-margin, top-system-spacing, last-bottom-spacing,
> left-margin, right-margin, paper-width, but none of them seem to work

I'm afraid that it won't work out of the box. The cropping seems to take
place after the image is composed and doesn't care about margin or indent
settings. 
My only idea would be to place invisible stuff around like, 
\set Staff.instrumentName = \markup \with-color #white "X"
but I don't think this will result in a usable workflow.

Maybe it's easier to add margins with an image editor that has automatic
batch processing like IrfanView.


Cheers, 
Klaus






--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Png-cropping-tp200437p200441.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread renyhp
Hi,
Thank you for your answers. I am actually programming something automated (a
Telegram bot for LilyPond! If you are on Telegram you will find it at
@lilypondbot), so probably the best option will be to discard using
LilyPond's cropping feature and try to find another way to crop it myself.
It is a bit sad, though, that a so powerful tool like LilyPond can't adjust
some simple things like png output margins.
Best regards,
  Renato



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Png-cropping-tp200437p200445.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread Simon Albrecht

Am 25.02.2017 um 12:01 schrieb renyhp:

It is a bit sad, though, that a so powerful tool like LilyPond can't adjust
some simple things like png output margins.


That’s not the best wording. LilyPond is a very powerful tool, because 
volunteers have invested their time and abilities to create solutions 
for what use cases they saw coming. IIUC, the PNG cropping has been 
designed for use with lilypond-book, at any rate the developers didn’t 
see any need for adjusting the margins. If you want to change it, you 
are very welcome to propose patches, or file a concise enhancement 
request with bug-lilyp...@gnu.org.
Certainly there are many (seemingly) small features missing from 
LilyPond’s toolset, but that’s no reason for any kind of accusations. 
Try rephrasing the sentence as ‘Wouldn’t it be great if there were some 
possibility to adjust margins with the PNG cropping mechanism?’ – that 
sounds a lot more appropriate.


Best, Simon

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread SoundsFromSound
renyhp wrote
> I read in the documentation that it is possible to create a cropped png by
> using "-dbackend=eps -dresolution=600 —png" and inserting this \paper
> block:
> 
> However, I think the cropping is too heavy. How can I produce a png with
> some nonzero margins? 

If you use Frescobaldi, you can save a PNG of a selected area of your score
by dragging and dropping it, it's pretty straight forward and I've had
success doing it in the past.

Perhaps that could help you?




-
composer | sound designer | asmr artist 
LilyPond Tutorials (for beginners) --> http://bit.ly/bcl-lilypond
--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Png-cropping-tp200437p200451.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread David Wright
On Sat 25 Feb 2017 at 02:26:53 (-0700), Klaus Blum wrote:
> Hi Renato, hi Andrew,
> 
> Andrew Bernard wrote
> > why would you use backend = eps if you are generating a PNG file? I think
> > you can omit that.
> 
> The auto-cropping features only work with the EPS backend which can also be
> used to generate PNG or PDF output. 
> Making use of 
> \include "lilypond-book-preamble.ly"
> has the same effect.
> 
> 
> Renato-23 wrote
> > How can I produce a png with some nonzero margins? I've tried to add
> > top-margin, bottom-margin, top-system-spacing, last-bottom-spacing,
> > left-margin, right-margin, paper-width, but none of them seem to work
> 
> I'm afraid that it won't work out of the box. The cropping seems to take
> place after the image is composed and doesn't care about margin or indent
> settings. 
> My only idea would be to place invisible stuff around like, 
> \set Staff.instrumentName = \markup \with-color #white "X"
> but I don't think this will result in a usable workflow.

I tried lilypond-book last year and IIRC it even does things like
stripping off the opus from the top system and reassembling the
cropped fragments itself, so workarounds like this might not work
in any case.

> Maybe it's easier to add margins with an image editor that has automatic
> batch processing like IrfanView.

Cheers,
David.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread karl
> renyhp wrote
> > I read in the documentation that it is possible to create a cropped png by
> > using "-dbackend=eps -dresolution=600 —png" and inserting this \paper
> > block:
> > 
> > However, I think the cropping is too heavy. How can I produce a png with
> > some nonzero margins? 

Have you tested adding margins with pnmpad as in
 pngtopnm input_file |
 pnmpad -white  -left 10 -righ 10 -top 10 -bottom 10 |
 pnmtopng > padded.png

Regards,
/Karl Hammar

---
Aspö Data
Lilla Aspö 148
S-742 94 Östhammar
Sweden
+46 173 140 57



___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread David Wright
On Sat 25 Feb 2017 at 04:01:43 (-0700), renyhp wrote:
> Hi,
> Thank you for your answers. I am actually programming something automated (a
> Telegram bot for LilyPond! If you are on Telegram you will find it at
> @lilypondbot), so probably the best option will be to discard using
> LilyPond's cropping feature and try to find another way to crop it myself.
> It is a bit sad, though, that a so powerful tool like LilyPond can't adjust
> some simple things like png output margins.

IMO that would be like going to the tile store and having to
buy tiles with 3mm of grout round them. One buys clean tiles
and applies grout of desired width when they're laid.

In my workflow, I don't use PNGs because they're already rasterised,
which messes up rescaling. PDFs are much better, and there's a tool
for cropping them, pdfcrop, which is bundled in the TeX Live
distribution, which LilyPond users are likely to be already using:
$ pdfcrop --margins  in.pdf out.pdf

Adding facilities to LP for manipulating PNGs would be a big
duplication of time and effort IMO. After all, where do you stop?
$ gm convert -negate -trim -bordercolor red -border 10x0 -bordercolor green 
-border 0x8 in.png out.png
looks like an over-the-top command you might use. It will convert the
image to white on black, trim it (by inspecting the colour of the
corner pixels), then add coloured borders to the sides and the top and
bottom. Just prune that command to taste.

Cheers,
David.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread Renato Fiorenza
Hi Simon, hi David,

I am very sorry. I absolutely did not intend to make any sort of accusation. I 
did word the phrase badly, led by the too impulsive thought that I couldn't 
believe that LilyPond, even being so powerful, couldn't do what I thought it 
would be certainly able to do.

Actually, after reading your replies, I realised why this behaviour is actually 
intended and indeed much more rational than giving the option of cropping the 
png as the user wants. I will surely follow your suggestions of adding margins 
to the cropped png, instead of trying to crop the full one.

Thank you for your replies.
   Renato
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Png cropping

2017-02-25 Thread Renato Fiorenza
Hi,
Thank you for your replies. Using a GUI like Frescobaldi is not really 
something I can do while programming. However, I can surely insert margins to 
the cropped png, which is definitely what I am going to do.
Best regards,
  Renato
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user