views:

2172

answers:

2

I'm trying to convert a PDF (at least the cover of one, I'm successfully extracting the first page of the PDF with pdftk) to a PNG. I'm using imagemagick to do the converstion:

convert cover.pdf cover.png

This works, but unfortunately the cover.png comes through incorrectly rendered (some of the alpha object in the PDF aren't rendered properly). I know ImageMagick uses GhostScript to do the conversion and if I do it directly with gs I can get the desired results, but I'd rather use the convert library as it has other tools I'd like to leverage.

This command in GhostScript accomplishes the desired image:

gs -sDEVICE=pngalpha -sOutputFile=cover.png -r144 cover.pdf

I'm wondering is there any way to pass arguments through convert to GhostScript or am I stuck with calling GhostScript directly?

+1  A: 

Here is a german discussion about a problem like this for SVG files where it is solved by using

convert -background transparent

Perhaps this works for you, too.

schnaader
Sadly no that doesn't solve my problem. It's actually an image in the PDF that has an alpha channel that sits on top of everything.
Adam
A: 
pipitas