Page 1 of 1

Different levels of sharpness on identical vertical lines

Posted: 2017-03-27T07:30:39-07:00
by Schlendrian
When I convert this pdf file* to a png using ImageMagick, one of the lines is sharp and the other is blurry.

I'm using ImageMagick Version 7.0.4-9 Q16 x64 2017-02-14 under Windows 10 with the command line tool.

I have tried different settings, but couldnt get rid of the problem. Two example images:

convert -density 100 example.pdf -background white -alpha remove -quality 90 withoutSharpen.png
convert -density 800 example.pdf -resize x1080 -background white -alpha remove -sharpen 2.2x0.62 -quality 90 withSharpen.png

Does anyone know what might be causing this behaviour?


*I created the pdf using LaTeX. The image in it was created using the tikz package.

Re: Different levels of sharpness on identical vertical lines

Posted: 2017-03-27T09:47:40-07:00
by snibgo
This is a quantum effect (aka anti-aliasing), caused by rasterizing the vectors. It will depend on the x-coordinate of the lines, and whether the distance between them is a multiple of the density.

"-density 90" or a multiple of 90 seems to give the same effect to both lines.

Re: Different levels of sharpness on identical vertical lines

Posted: 2017-04-03T06:06:47-07:00
by Schlendrian
Thank you for the reply. I'm sorry I didnt answer sooner. Didnt seem to be able to find the time to try around a bit using the information you provided.

Anyway, I did manage to try some things now:
- I converted the example.pdf with a lot of different densities. Indeed, they all look different. (I could use a for-loop to convert the image using many different densities and then pick the best-looking one.)
- Using the +antialias option, the lines are both sharp. However, most other elements (text or circles, for example) in the pictures I want to convert are influenced negatively, since they then actually look like theyre made out of rectangular pixels
- I split one of my tikzpictures into its different "layers", converting the vertical and horizontal lines with the +antialias option and the rest without it. Then I composed the images using -layers flatten. The result looks really good, but I have too many images to convert to be doing this by hand for all of them.

Is there something else I could try? Or a better way to do what I already tried?
Maybe I should also read up on the things you mentioned. To get a better understanding of the problem myself.