I would like to convert a pdf drawing to png, and would like if pdf drawing line width is 1, then converted png output is 1 pixel. for example:

    \draw (0,0) -- (1,1) -- (1,0) -- cycle;

If I use convert -density 72 input.pdf output.png, I got below output png (dimension is 31x31):

enter image description here

But if print the R value of each pixel in the png file, I got below output:

enter image description here

The right line is 1 pixel exactly, the bottom line used 2 pixel, and the diagonal line used 3 pixel.

I would like all lines output with 1 pixel.

1 Answer 1


This is related to antialiasing. Switch it off with +antialias (syntax might be confusing, but switching it on, which is default, would be -antialias):

convert -density 72 +antialias triangle.pdf triangle.png


enter image description here

  • Great, that's what I want exactly! which software are you using to view image pixel by pixel? I use xviewer on linux but it seems not pixel by pixel.
    – lucky1928
    Apr 29, 2021 at 18:13
  • @lucky1928 it is a coincidence rather, the converted png has a transparent background and my image editor (Kolourpaint) shows transparency as a checkerboard of grey and white single pixels.
    – Marijn
    Apr 29, 2021 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .