Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

imagemagick convert pdf with transparency to jpg

When converting a PDF with images with transparency, the output ends up with a black background

convert -density 300 -background white -alpha off \
-resize 80x80 -strip -quality 70 file.pdf[0] thumb.jpg[0]

Have tried to set the background to white and deactivate alpha, but the background still ends up black!?

Test file

http://www.bluemachines.dk/pdf/trans.pdf

Have tested on these two versions so it looks like a generel "issue"

ImageMagick-6.8.8-10

ImageMagick-6.7.7-10

update

# /var/bin/ImageMagick-6.8.8-10/utilities/convert
Version: ImageMagick 6.8.8-10 Q16 x86_64 2014-04-10

 # gs -v
GPL Ghostscript 9.14 (2014-03-26)

Here is the output file

http://www.bluemachines.dk/pdf/thumb.jpg

-debug ALL

Can't post that much in the body so the output is pasted into this txt file

http://www.bluemachines.dk/pdf/debug.txt

like image 821
clarkk Avatar asked Apr 10 '14 16:04

clarkk


1 Answers

You should use -alpha remove instead of -alpha off. And I would advise you to change the order of your arguments to this:

convert -density 300 file.pdf[0] -resize 80x80 -background white -alpha remove \
-strip -quality 70 thumb.jpg
like image 164
dlemstra Avatar answered Oct 23 '22 20:10

dlemstra