[gs-devel] Yet another problem converting transparent PDF to transparent PNG

ansgar ansgar.simon at brandad-systems.de
Thu Aug 11 10:57:32 UTC 2011

Hi Chris,

Thank you for your fast response!

First of all I would be very happy if you''ll be able to invest more time 
in enhancing the pngalpha-device, ‘cause of a few more problems with 
transparency I encountered in the past. Just say “transparence gradients”.

But let's get back to how we generate the PDF. 
At the beginning our process is as follows: 
We convert a TIF automatically with the help of PhotoShop in a PDF.

Here’s a brief description of our workflow:
• data input -> .TIF (grayscale or bitmap, see
• open the file with Photoshop
• convert into grayscale (coherent starting point)
• convert to bitmap (only monochrome pixels)
• remove white background
• crop unnecessary content
• finished (see http://www.webknack.de/ghostscript/sample.pdf)

Do you recognize any errors or problems? 

Your idea you mentioned above does not work unfortunately, 
because I didn’t find a way to get an ImageMask on a 1 bit graphic, 
with PhotoShop. If you thought of a LayerMask, the outgoing was the same 
-> pngaplha drops back to white, not to transparency (see

(We usually use the PDFs wrapping it 1:1 into other PDFs by using the
In this process there are now problems with transparency at all. 
But for screen view we need to get a transparent PNG out of the PDF.)

best regards

Chris Liddell wrote:
> You can't - it's that simple.
> Note that there is really no such thing as a "transparent PDF", rather
> there are PDF files which contain transparency operations. The PDF
> imaging model is defined as rendering to an opaque back drop.
> Having said that, the pngalpha device bends that slightly, but there is
> an incompatibility between Ghostscript's implementation of PDF
> transparency and pngalpha's implementation which means that "bending" of
> the imaging model doesn't work.
> Basically, each transparency group (including its backdrop) becomes a
> single marking operation, so ultimately, the page group is the final
> marking operation which, by implication, covers the entire page.
> The marking operation representing the entire page group is what the
> pngalpha device receives and writes to the output file.
> Having said that, recent internal changes in Ghostscript should mean
> that the "infrastructure" is in place to to have pngalpha work as you
> want, but no time has been available (or looks like being available for
> a while) to have the device take advantage of it.
> BTW, I could find no way to get Acrobat to emit a png with a transparent
> backdrop - the png Acrobat 9.x produces for me looks like the one
> Ghostscript currently produces, so from that point of view, we currently
> do match the de-facto PDF benchmark.
> For what it's worth, a much better way to represent what you are trying
> to create with that file would be to make your image a monochrome (1
> bit) image, and draw it as an imagemask (not using PDF transparency at
> all) - the rendering will be quicker, and you should get the png with
> transparency backdrop that you want.
> Chris
> On 02/08/11 08:46, ansgar wrote:
>> Hi all,
>> I'm struggling with a imo correct transparent PDF (works pretty in
>> Acrobat,
>> PhotoShop...) converting in a hopefully equally transparent PNG, but the
>> PNG-background still remains white. 
>> With "Dr. Googles" help i tripped over some interesting workarounds in
>> order
>> to convert the white background after GhostScript into real transparency
>> with ImageMagik. But sadly those workarounds don't work for me, 'cause of
>> ImageMagik dully converts all white pixels into transparency, whether
>> formerly transparent in PDF or not.
>> So, I'm asking for help to convert my PDF effectively only with
>> GhostScript
>> into a transparent PNG.
>> The GhostScript command I'm using is:
>> gs -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dFirstPage=1 -dLastPage=1 -r72x72
>> -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dUseCIEColor
>> -sOutputFile=output.png input.pdf
>> My input.PDF is located at:
>> http://www.webknack.de/ghostscript/input.pdf
>> The output.PNG can be seen here:
>> http://www.webknack.de/ghostscript/output.png
>> See also, proof of white background: 
>> http://www.webknack.de/ghostscript/test.html
>> How can i tell GhostScript to handle the transparency correct??
>> Thanks in advance for all your help!
>> Regards
>> ansgar
> _______________________________________________
> gs-devel mailing list
> gs-devel at ghostscript.com
> http://ghostscript.com/cgi-bin/mailman/listinfo/gs-devel

View this message in context: http://old.nabble.com/Yet-another-problem-converting-transparent-PDF-to-transparent-PNG-tp32175667p32241108.html
Sent from the Ghostscript - Dev mailing list archive at Nabble.com.

More information about the gs-devel mailing list