Different levels of sharpness on identical vertical lines

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
Schlendrian
Posts: 2
Joined: 2017-03-27T05:47:48-07:00
Authentication code: 1151

Different levels of sharpness on identical vertical lines

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Different levels of sharpness on identical vertical lines

Post 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.
snibgo's IM pages: im.snibgo.com
Schlendrian
Posts: 2
Joined: 2017-03-27T05:47:48-07:00
Authentication code: 1151

Re: Different levels of sharpness on identical vertical lines

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