Hey David,

-danti-alias-factor looks great - thanks for the suggestion - but I believe
it won't work for (extremely) large, transparent images...  Unless
Ghostscript is called with the option -dMaxBitmap=2147483647 (or similar)
from within LilyPond. The reason is that without that option set,
Ghostscript will revert to the png16m device (rather than the pngalpha
device) for extremely large images, presumably because of memory reasons...
and with png16m instead of pngalpha I will loose the transparency, which I
don't want to...

If Ghostscript was run with this dMaxBitmap option automatically, then I
think it would work, or if I was able to specify this option somehow during
lilypond runtime? Is that possible?

Cheers,

Erik

PS: Pasting the previous discussion regarding GS / pngalpha / png16m for
reference.

------------

Regarding how to create large, transparent scores:

When the images you output are reasonably small, 'lilypond... --png ...
-dpixmap-format=pngalpha ....' successfully generates the transparent
images. Once the images surpass a certain size however, transparency seems
to fail, and the .png images come out with a white background.

If you run the following lilypond command: 'lilypond --png -dresolution=100
-dpixmap-format=pngalpha --ps --verbose x.ly'

and look at the bottom of the log, you can see the actual Ghostscript
command called by Lilypond used to create the .png. It is going to look
something like this:

gs  -dDEVICEWIDTHPOINTS=37533.99 -dDEVICEHEIGHTPOINTS=2160.00
-dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE -sDEVICE=pngalpha
-sOutputFile="./x.png" -r100 "x.ps" -c quit

As you can see it is correctly using the device 'pngalpha' in order to
generate the transparent image. The problem seems to be that - upon
inspecting the logs - Ghostscript reverts to the device png16m instead,
which is unable to generate a transparent image.

The way to fix this is to tweak the memory usage options for Ghostscript,
specifically by adding the option '-dMaxBitmap=2147483647' to the
Ghostscript command, as in the following snippet:

gs  -dDEVICEWIDTHPOINTS=37533.99 -dDEVICEHEIGHTPOINTS=2160.00 -dMaxBitmap=
2147483647 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dNOPAUSE
-sDEVICE=pngalpha -sOutputFile="./x.png" -r100 "x.ps" -c quit

This allocates more memory to Ghostscript and makes it correctly use the
pngalpha device, and thus correctly output a transparent image. If you have
a 64 bit machine perhaps you can extend it further. It should also be
possible to rebuild lilypond from source and compile it with this option
baked in, but I haven't tried that....

Perhaps this information helps someone trying to create large, transparent
images in LilyPond!

On Fri, Feb 14, 2014 at 1:38 AM, David Kastrup <[email protected]> wrote:

> Erik Linde <[email protected]> writes:
>
> > Hey Chris / David,
> >
> > Adding the --png option when you run your lilypond command works fine (as
> > David stated)... Also, you may want to set the -dresolution parameter to
> > something high like 300 (DPI) to get a good resolution. Or even set it to
> > 600, and then shrink it to 300DPI using some image processing software
> such
> > as Photoshop or ImageMagick / GraphicMagick to achieve an even better
> > anti-aliasing effect.
>
> Why would you do that manually rather than using the
> -danti-alias-factor=2 option?
>
> --
> David Kastrup
>
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to