openlilylib / LO-ly

LibreOffice-LilyPond extension
13 stars 6 forks source link

add option for transparent PNG background #23

Closed yfede closed 5 years ago

yfede commented 5 years ago

Instead of having a white background in PNGs, it is possible to have a transparent background adding this option to the lilypond command line:

-dpixmap-format=pngalpha

Would it be possible to add an option on the GUI for that? Having transparent PNGs is useful when pasting the score over a colored background.

Details here: http://lilypond.1069038.n5.nabble.com/png-output-with-transparent-background-td81886.html

KlausBlum commented 5 years ago

Yes, that can easily be done. In the next few days, I'm going to prepare a new release, and it's no problem to include that option.

Would it be a usable way to have four "Format" options, i.e. "png, png (transparent), eps, svg"?

Second answer: If you are using LibreOffice, you can use svg graphics. They offer a better quality and have a transparent background. There are some preparations to be made which are described here: http://lilypondblog.org/2018/02/ooolilypond-part-2-optimizing/

Third answer: If you want to have transparent PNGs available immediately, you can edit you OOoLilyPond macro. In the LibreOffice Menu, go to Tools > Macros > Edit Macros Now the LibreOffice Basic Window should open. On the left side, locate the OOoLilyPond macro and choose the sub-module "LilyPond". In the code at the right side, go to line 26 (Linux/Mac) or line 43 (Windows). It should start like this: sCommand = sCommand & " -dno-delete-intermediate-files --png "...etc... Now you can add your code snippet: sCommand = sCommand & " -dno-delete-intermediate-files -dpixmap-format=pngalpha --png "...etc... Finally, save your changes. This should do the trick.

Cheers, Klaus

yfede commented 5 years ago

Would it be a usable way to have four "Format" options, i.e. "png, png (transparent), eps, svg"?

Yes, that will certainly be ok. Perhaps, it could be specified that the other, usual png format is "png (white background)", so that it is clear the rationale for distinguishing between the two?

If you are using LibreOffice, you can use svg graphics. They offer a better quality and have a transparent background. There are some preparations to be made

Yes, I've noticed that there was the SVG output and have tried that, but since it did not work "out of the box", for the time being I resorted to PNG instead of searching for a solution to make it work.

If you want to have transparent PNGs available immediately, you can edit you OOoLilyPond macro.

Thank you for explaining, I guessed that this kind of possibility but I'm totally new to the realm of Libre/Openoffice extensions, and didn't know where to look.

KlausBlum commented 5 years ago

It turned out that a fourth "Format" option would not be the best way. Instead, there will be a new checkbox "Transparent Background for png" and an additional helptext "Create png graphics without opaque white background (svg never has a white background)". screenshot2

KlausBlum commented 5 years ago

Done... it's available in Release 0.5.8.

It feels good to close an issue. =)