Keeping Anti-alias while turning off Alpha for Backgrounds

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
oguru
Posts: 2
Joined: 2015-02-20T14:43:25-07:00
Authentication code: 6789

Keeping Anti-alias while turning off Alpha for Backgrounds

Post 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?
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post by glennrp »

Try making a PNG with alpha enabled, then compose that over a white canvas of the desired size.
oguru
Posts: 2
Joined: 2015-02-20T14:43:25-07:00
Authentication code: 6789

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

Post 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
Post Reply