ImageMagick PDF to JPGs sometimes results in black background

Ran into this one today, found this:

https://www.imagemagick.org/discourse-server/viewtopic.php?t=20234

Based on that, these should all work:

  • -flatten
  • -alpha flatten
  • -alpha remove

I'm currently using the below for my specific case which works great:

convert -thumbnail "1280x800>" -density 300 -background white -alpha remove in.pdf out.jpg

Simple fix to this issue is to use an image format that supports transparency, such as png.

So:

convert -density 175 -colorspace sRGB test.pdf -resize 50% -quality 95 test.png

Problem solved :)


If you want a high quality result, use this command:

convert -density 700 input.pdf -resize 25% -append  -quality 98 -alpha remove output.jpg

For windows users, use magick instead of convert