Skip to content

Sharing Tab and Standard Notation Images

In my previous post, How’d I get that tab, notation and chord diagram into my blog?, I listed 6 examples of things you might want to be able to do if you teach or write about music. Here’s the list again.

The examples are:

  1. Put the guitar tab of a C major scale into HTML for a blog.
  2. Create a high quality image of the tab which can be put anywhere.
  3. Create a high quality image of the tab + standard notation.
  4. Create the standard notation of a C major scale (not tab) and an image for embedding.
  5. Create a chord diagram of a C major guitar chord played as a bar at the third fret.
  6. Create a finger diagram of the note positions for a C major scale placed in the cAged position on the guitar.

[jbox vgradient=”#d8d8d8|#ffffff”]This is Part 2 in my series Musical Snippets for Sharing.[/jbox]

I covered Example 1 in the previous post. This time I’m going to cover examples 2 and 3. Example 2, TAB and Example 3, TAB + standard notation both will require a fretted instrument tab editor. My recommendation is Tux Guitar because it is free, open source and available for Windows, Mac and Linux. But if you own another editor, e.g., Guitar Pro, TablEdit or other, you can probably use it for most of the methods I provide.

Before I go on, I want to first make clear that if you want to share tab and notation with others, the two best options are to save and share in the software format that allows someone with the same program to open it, or save it as a PDF that can be printed anywhere. The problem we are trying to solve today is to blog or share fragments of music where the recipient may not have nor need the required software. In other words, we want to embed a small piece in a document, email or web site. This requires an image.

Easiest Method (but poor quality image and difficult to format).

An easy way to get an image of tab and notation for embedding is to simply take a screenshot of what you want. Here’s some reasons why that is not a good idea. First is your tab editor is designed to make it easy to enter tab or to view a score on a computer. It is not formatted for display in web page. The bars probably will wrap in a way that makes it difficult to capture more than a few bars without problem.

Tux Guitar on screen display:

On screen display in Tux Guitar scrolls off screen

You can get a higher quality image by taking a screenshot of the Print Preview display. You can get an even higher resolution on screen image that can be scaled by saving the tab as a PDF, opening the tab, scaling the document in your PDF viewer and taking a screenshot of the result.

Print Preview screen shot:


PDF screen shot:

tg-pdf-imageTux Guitar does not have page setup properties. Some other programs such as Guitar Pro 6, allow you to set the paper size, including to custom sizes. This allows you to better control where bars wrap.

Best Method

The best method I’ve found is to export your tab to lilypond and then edit the exported source file (.ly).

Here are the first 12 lines of a lilypond file I exported from TuxGuitar.

#(define (tie::tab-clear-tied-fret-numbers grob)
  (let* ( (tied-fret-nr (ly:spanner-bound grob RIGHT) ) )
    (ly:grob-set-property! tied-fret-nr 'transparent #t) ) )

\version "2.10.5"
\paper {
  indent = #0
  printallheaders = ##t
  print-all-headers = ##t
  ragged-right = ##f
  ragged-bottom = ##t

The version number is an issue we will address soon. For now the thing to remember is that the current version of lilypond is 2.14 (or higher depending when you read this and the developers update the software). If you already have lilypond installed, you may not have any problems but if you’ve just installed or upgraded the newest version of lilypond, some of the syntax may be out of date. Don’t worry. We can fix it.

We want to edit the \paper block of code (lines 6 to 12 above).

Here’s the code we want to use to replace the current \paper block:

  bookTitleMarkup = ##f
  scoreTitleMarkup = ##f

The purpose of most of the new code is to remove extraneous items from the output so we can produce a simple image suitable for use as an embedded example. However, the “line-width=120\mm” in line 8 is important. It sets the maximum width for the output and controls where new lines will start. Note that the width measurements are for printed output and do not translate directly into pixels.

The next problem is how to get lilypond to produce a PNG image. The answer has multiple parts. The first part is we need to “compile” the lilypond source file from a command line where we can add a directive that causes each page of output to be saved as a PNG image 1. The simple form for this is (in a command window) 2:

lilypond --png

However the above won’t get us the nice, compact snippet of just the music. It will instead produce a full page sized image. Here’s the code you need instead 3:

lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png

This is getting complicated. I’ve therefore written a batch file for windows so I don’t have to remember the above command line. It also runs an updater to fix version incompatibilities. So far I have not automated replacing the \paper block in the source code – so you need to save the instructions and code for that so you copy and paste the code when you need it.

Here’s the windows batch file source code. Sorry, I don’t have shell scripts written for Mac or Linux but I’m sure they could be written to automate this on those platforms too.

REM updates old versions to current 2.14.+ or the version you have installed
convert-ly -e

REM The --png creates png image for each page of score
REM The rest of this is to get
REM compact graphic instead of full page
lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png

REM This cleans up extra intermediate files if they were created
IF EXIST %1*.eps del %1*.eps
IF EXIST %1*.count del %1*.count
IF EXIST %1*.tex* del %1*.tex*

To use this, first copy and paste the above into a plain text editor and save as something.bat. I’ve named mine runly.bat. Then from a command line type the following.

runly yourfile

Here’s the output that my example produced.


The PNG is only as big as needed to contain the notation. If I change line 8 in the source to line-width=60\mm the lines break after every 2 bars.

You can also get rid of the tempo info by searching for \tempo in the source code and removing the line. You can place the percent sign % in front of the line to “comment out” the \tempo line. The following image is at 60mm and the tempo line is commented out.


Example 4: Create the standard notation of a C major scale (not tab) and an image for embedding.

I’ve debated expanding a discussion of this example to it’s own post. But, for now, I’ll keep it here. The recommended method is to create the score in MuseScore, export it to Lilypond, edit the Lilypond source .ly file and run the same command line to compile the lilypond as for the two examples above.

The discussion is why would you need MuseScore or any other notation software. Just use TuxGuitar, right? If you play a stringed instrument that has frets, then that’s a good idea. TuxGuitar will allow you to display the standard music notation only or export only the notation to lilypond. You may find it easier to enter notation in TAB even if you only need standard notation.

But, believe it or not, there are musicians who don’t play fretted instruments. Why would they want a tab editor? And MuseScore probably is better for creating a score with many parts for different instruments.

MuseScore can export a PNG directly, like Guitar Pro, and you are able to edit the paper size within MuseScore. But the lilypond export is still better for creating an example of music in a small graphic that can be embedded.


  1. Lilypond documentation refers to the process of converting the source code .ly file into a PDF or image as “compiling” the file. 
  2. Opening a command window in Windows and getting lilypond or other scripts to run requires the proper setup. See the lilypond documentation for information on how to modify your path settings in windows so scripts can find lilypond. You can open a command window in XP by typing in CMD in the Run.. dialog in the start menu. Windows 7 has a shortcut to open a command window in a folder by holding the shift key while right clicking in the folder and selecting “Open Command Window here” from the context menu.
  3. You don’t need to include the .ly at the end of the filename in the command line to run lilypond.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.