Trouble Converting Transparent PDFs to Transparent PNGs
Posted: 2009-06-09T16:21:20-07:00
Hi all. I'm hoping for some help with something I've spent several hours trying to figure out to no avail...
I need to convert PDF files with a transparent background to PNG files with a transparent background, but no matter what I do, ImageMagick (using ghostscript) rasterizes my PDFs with a white background color.
Unfortunately, I can't simply use a command like "convert -transparent white test.pdf test.png" to make all the white pixels in the converted image transparent, even if I use a fuzz factor, since the graphics in the PDFs have drop shadows that I need to preserve. I have also been unsuccessful using -background transparent and -alpha on, while -alpha transparent gives me a blank image, 100% transparent.
My feeling is that somehow I need to tell Ghostscript (either directly on the command line or through ImageMagick) to rasterize the PDF with a transparent background before it gets to ImageMagick.
Perhaps the problem is somewhere in the PDF file, since when I run "identify -verbose test.pdf", IM tells me that the pdf has "background color: white". Howerver, I suspect that this is just the default background color and that a background color is actually not defined in the PDF -- when I open the PDF in Photoshop, it shows up with a transparent background.
Trying to convert the file directly with Ghostscript, the closest I can get is to use this command:
With this command, any pixel totally outside one of the bounding box of the artwork is set to transparent, but the drop shadows and everything else inside of the artwork's bounding box is rasterized against a white background.
Can anybody help me out, or point me to a better forum to post my question? (I lookef for a forum for Ghostscript questions after learning that IM uses GS for PDF rasterization, but all the ghostscript advice related to this issue was either here on this forum or posted on other ImageMagick discussion areas.)
The sample PDF that I'm trying to convert to a transparent PNG can be found here: http://www.kolossus.com/files/test.pdf
Finally, I am running ImageMagick 6.5.2-9 and Ghostscript 8.64 on Mac OS 10.5.7.
Thank you in advance for any pointers or advice.
-Jon Wolfe
I need to convert PDF files with a transparent background to PNG files with a transparent background, but no matter what I do, ImageMagick (using ghostscript) rasterizes my PDFs with a white background color.
Unfortunately, I can't simply use a command like "convert -transparent white test.pdf test.png" to make all the white pixels in the converted image transparent, even if I use a fuzz factor, since the graphics in the PDFs have drop shadows that I need to preserve. I have also been unsuccessful using -background transparent and -alpha on, while -alpha transparent gives me a blank image, 100% transparent.
My feeling is that somehow I need to tell Ghostscript (either directly on the command line or through ImageMagick) to rasterize the PDF with a transparent background before it gets to ImageMagick.
Perhaps the problem is somewhere in the PDF file, since when I run "identify -verbose test.pdf", IM tells me that the pdf has "background color: white". Howerver, I suspect that this is just the default background color and that a background color is actually not defined in the PDF -- when I open the PDF in Photoshop, it shows up with a transparent background.
Trying to convert the file directly with Ghostscript, the closest I can get is to use this command:
Code: Select all
gs -q -dNOPAUSE -dBATCH -sDEVICE=pngalpha -sOutputFile=test.png test.pdf
Can anybody help me out, or point me to a better forum to post my question? (I lookef for a forum for Ghostscript questions after learning that IM uses GS for PDF rasterization, but all the ghostscript advice related to this issue was either here on this forum or posted on other ImageMagick discussion areas.)
The sample PDF that I'm trying to convert to a transparent PNG can be found here: http://www.kolossus.com/files/test.pdf
Finally, I am running ImageMagick 6.5.2-9 and Ghostscript 8.64 on Mac OS 10.5.7.
Thank you in advance for any pointers or advice.
-Jon Wolfe