4

My question concerns the creation of images using lilypond. Until know I've created some music sheets and lilypond has been really great. However I have a website and I would like to post some examples to illustrate what I'm saying. The images should just fit the size of what is written. It will mostly been 2-3 bars max, but I would like the size to fit automatically as it could be bigger.

When I use the --png option, it creates an image the size of an A4 page. I tried using the snippets shown in the doc, for exemple here : http://lilypond.org/doc/v2.12/input/lsr/12/lily-1ed76b9d.ly

If I comment the \include "lilypond-book-preamble.ly", then it shows as an A4 document. If I leave it, then I'm asked to add -dbackend=eps to the command line. If I add it, then it actually produces the result i'm searching for. However it also adds a whole bunch of files (multiple .pdf, .eps, .tex, .texi, .count).

Is there a proper way to do it, or should I write a bash script to clean the folder after the lilypond command?

Another thing: with the --png option, are we able to define an image size? I'm able to change it using -dresolution but it's not very handy as you have to try to see the output size, then change and try again... Maybe is it better to create .pdf and use other scripts to convert into .png?

Thank you in advance! I searched for this information but found very little about it so far...

1

From what I understand, LilyPond momentarily produces all of the file types you mentioned (.pdf, .eps, .tex, .texi, .count) and automatically scrubs them unless it is suppressed in the lilypond file itself or you direct the program to clean the directory of those files.

Personally, I use a GUI called Frescobaldi to grab my images. It's really easy (although you may be looking for a less involved way of doing it):

  1. Generate your lilypond file
  2. Go to the preview and shift+click around the example you want (producing a light gray box around the area) Note: It does not need to be precise
  3. Right-click > Copy to Image... and choose what resolution, Antialiasing (if you want) and (GASP!) Auto-crop! Make sure you don't forget your suffix.

EDIT: If it is unclear, I'm saying you need to write a bash script to scrub the directory of those files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.