Skip to content

File formats bitmap vs. vector

Klaus Blum edited this page Apr 3, 2022 · 8 revisions

File formats - bitmap vs. vector

ANNOUNCEMENT
OOoLilyPond has moved to a new repository:
https://github.com/OOoLilyPond
All past/present/future development can be found at the new location. The page you are viewing right here contains all development up to V. 1.0.1, but it will no longer be maintained.

This page is an explanation of the general difference between bitmap formats (.png) and vector formats (.pdf, .svg, .eps) in OLy.

OLy allows you to choose between different file formats. What reasons are there to switch from PNG files to another format?

PNG files are easy to handle, but being a bitmap format, they don't offer the best image quality:

OLy02 - png150

Bitmap images have a certain resolution given in dpi (dots per inch). The above picture is an excerpt of a 150dpi .png file that shows a simple {bes'4} at a staff size of 20 (LilyPond's default value). When magnified like this, the quality drawbacks are obvious.

In its config dialog, OLy lets you specify a resolution for .png files. Increasing the image resolution will also increase its quality. By default, a value of 300dpi is used, which will make the same excerpt look like this:

OLy02 - png300

Modern printers have a resolution of at least 600dpi. Therefore, this would be the minimal value to get usable print results:

OLy02 - png600

But still you can see that it is a rastered image. The transitions from black to white look somewhat blurred. Better quality can be achieved with vector file formats. They use polygons and curves to describe the outline of every object contained in the file. Therefore they provide perfectly sharp edges at any level of magnification:

OLy02 - svg

To keep up with that high quality, one would have to further increase png resolution, which, however, would make the file size explode. The tiny examples above had 2248 bytes (150dpi), 4395 bytes (300dpi) and 9076 bytes (600dpi) as their file sizes, whereas the .svg version had 3568 bytes: Only the worst of the above .png files was smaller.

LilyPond can produce various vector file formats: Apart from .pdf, certainly its most important format, also .ps, .eps and .svg are available. However, LibreOffice cannot handle all of them:

.eps images can only be used in OpenOffice, with the further limitation that they are not visible on screen and in pdf output (at least, for Windows there's a workaround). In LibreOffice, they cannot be used at all. Neither LibreOffice nor OpenOffice can import .ps files.

Option 1: PDF to SVG

OLy supports calling an external converter to transform LilyPond's .pdf output into an .svg file. The latter can be imported into LibreOffice and OpenOffice without further restrictions. If you don't mind installing such a third-party converter, this might be the preferred option. If you want to make use of it, choose "pdf to svg" as file format and continue reading here: PDF to SVG.

(.pdf images can be imported into LibreOffice, but currently (November 2019) they are hereby converted to bitmap previews - with the quality drawbacks explained above. That's why they should be converted to .svg files.)

Option 2: SVG

As another alternative, there are .svg files which are easily mastered by LibreOffice (not by OpenOffice). However, using this format with OLy requires two additional actions: Installing some fonts and using special templates. The SVG format is presented here: SVG and SVG [dcrop].