Home > Software design >  Converting a PDF to PNG with anti-aliasing and transparent background
Converting a PDF to PNG with anti-aliasing and transparent background

Time:06-23

I am trying to convert a LaTeX-generated PDF file to a PNG file with anti-aliasing and a transparent background (white text on a black background). After having read the answer to enter image description here

ImageMagick image:

enter image description here

So where this leaves me is that I am satisfied with the anti-aliasing that pdftoppm provides. However, ImageMagick seems to have more functionality in now converting the anti-aliased image such that the black background is transparent. I have applied the approaches detailed in enter image description here

If on Imagemagick 7, change convert to magick.

If you want to keep the transparency and keep your text white, then

convert -density 600 text.pdf y.png

enter image description here

The image is above, but will look completely white and blend with the white background. So you will need to download it.

If you want black text on transparency, then

convert -density 600 text.pdf -alpha extract -alpha copy -channel rgb -negate  channel z.png

enter image description here

  • Related