Closed agarwalanirudh closed 1 year ago
It's because your pdf has a transparent background. PNG supports transparency so it appears grey. JPG does not support transparency so it sets the background black.
You need to choose a background color and then flatten the images:
The same thing happens with the convert
command:
convert sample.pdf bad.png
convert sample.pdf -background '#FFFFFF' -flatten good.png
I had tried background property but that didn't do the trick. Although flattening the layers did solve the problem. Thanks @justinfx for quick response :)
@justinfx , I realised another issue when using -flatten parameter. It worked fine for this PDF and any other single page PDF, but when I try with multi page PDF, it results in a single image. Where as earlier it used to generate image for each page.
Well, I know it's not a bug with this binding library. It's a general "how to" ImageMagick question. You might be able to get better help with learning to use ImageMagick via their forum? There aren't going to be a lot of eyes on this issue tracker for this, other than me trying to maintain the library.
Upon converting PDF to JPG, background is completely black, where as in PNG also it turned grey Original PDF: sample.pdf
Outputs: