Page 1 of 1

Keeping Anti-alias while turning off Alpha for Backgrounds

Posted: 2015-02-20T14:55:33-07:00
by oguru
Hi guys, I'm using ImageMagick to convert PDFs into PNGs. Some of the PDFs have a transparent background. I want the PNGs to have a white background (and remove the transparency).

This is the command we have now to disable the alpha channel:

Code: Select all

convert -alpha off -quality 95 -density 150x150 PDF_SOURCE -resize 1275x1650 IMG_DESTINATION
This removes the transparency, which is perfect, but also disables anti-aliasing for fonts (which we want to keep).

Is there a way we can have both, a white background for PDFs with transparency, and anti-aliasing enabled for fonts?

Re: Keeping Anti-alias while turning off Alpha for Backgrounds

Posted: 2015-02-20T15:10:09-07:00
by glennrp
Try making a PNG with alpha enabled, then compose that over a white canvas of the desired size.

Re: Keeping Anti-alias while turning off Alpha for Backgrounds

Posted: 2015-02-20T15:35:21-07:00
by oguru
Thanks glennrp for the help. Found it. "-alpha remove" accomplishes the task. But doubled the file size. Keeping the depth to 8 solved the size issue.

Code: Select all

convert -quality 95 -depth 8  -density 150x150 PDF_SOURCE -resize 1275x1650  -alpha remove  IMG_DESTINATION