Music: Practice & Theory Stack Exchange is a question and answer site for musicians, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :

If I comment the \include "", 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...

share|improve this question
Note that your link is to the documentation for the v2.12 version of the software. You may want to consider using a newer version, or looking at the documentation for the version that you are using. – Dave Feb 17 '14 at 20:18
Note that cross posting the same question on multiple sites is frowned upon, c.f. (…) – Dave Feb 17 '14 at 20:21
Sorry, i'm new here. I read several posts that said lilypond questions could belong in both, not that it was limited to one. Won't happen again. I also updated my lilypond version (the one in the depository is deprecated). – Fnor Feb 18 '14 at 1:59

I use the following as my header (since version 2.16):

    bookTitleMarkup = ##f
    scoreTitleMarkup = ##f
    \relative c' { c4 d e f | g a b c }

and compile it using lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png The resulting png files fit to the music. This does produce the extraneous (mostly TeX related) files; I do not know of a way around that.

share|improve this answer
Thanks, this gives me the expected result! However it also gives a lot of files I won't use (.eps, .tex, ...). Is there a way to handle it with lilypond or am I better off using rm? – Fnor Feb 18 '14 at 2:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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