ParadigmTheGreat
ParadigmTheGreat

Reputation: 21

Text rendered to monochromatic image file using Imagemagick looks disfigured

Wrote a line of code that uses Imagemagick's 'convert' utility to render a string of text:

convert -background white -fill black -pointsize 8 -font ARIAL.TTF label:"AaBbYyZz" +dither -monochrome text.png

Specifically, I'm using the ARIAL.TTF from a Windows 3.1 installation.

It kinda works, but sometimes the text looks strange. Lemme show you what I mean. Here's an example of what the string "AaBbYyZz" looks like in Win3.1 versus the image rendered by IM: (both are 8 pt)

How it appears in Win3.1:

How it appears in Win3.1

And here's how IM renders the exact same string, with the exact same TTF file, at the exact same point size:

IM's render

What causes this disfigurement, and what can be done to make it look as clean as the Win3.1 render, or at least make it look better?

Thanks in advance.

Upvotes: 0

Views: 98

Answers (2)

Glenn Randers-Pehrson
Glenn Randers-Pehrson

Reputation: 12465

You can either increase the pointsize to 11 or increase the "density" to 96. Both have about the same effect, but neither looks quite as good as the Windows rendering:

renderings

AS you can see, the appearance is improved if you use grayscale instead of monochrome.

I can't guarantee that I was using the same Arial font. I'm on a Ubuntu platform that doesn't have Arial, so I followed the instructions in this question to download and install one.

Upvotes: 1

GeeMack
GeeMack

Reputation: 5395

ImageMagick will also use the "-density" setting when rendering fonts. Your example as a Windows display font probably uses a resolution of 96dpi, and the default ImageMagick resolution is 72dpi. Try something like this...

convert -background white -fill black -density 96 -pointsize 8 ^
   -font ARIAL.TTF label:"AaBbYyZz" +dither -monochrome text.png

Upvotes: 0

Related Questions