Page 1 of 1

ImageMagick is rendering my tiny fonts really fat and ugly?

Posted: 2012-04-27T17:45:53-07:00
by BikeHelmet
Hi,

ImageMagick is rendering my tiny fonts really fat and ugly. I want to stamp a website location onto a Webcam image, but it's not readable.

Ideally it'd look like the thin fonts in this image:
viewtopic.php?f=1&t=19711
Image

But instead I'm getting results like this:
Image

It does it black on white too. I've tried playing with -StrokeWidth, +antialias, etc. - no effect. It just seems to want to render all text really fat/bold?

What am I doing wrong?

Code: Select all

convert "webcam_640x360.jpg"\
        -fill black -stroke black -draw "rectangle 0,344,640,360"\
        -fill white -stroke white -font Courier-New-Regular -pointsize 10 -draw "text 0,356 'www.SuperUglyWebcam.com/Webcam/'"\
        -quality 95 test_640x360.jpg

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T03:06:55-07:00
by BikeHelmet
Getting rid of the -stroke option helped a little bit.

Adding +antialias got rid of the blurring, but the text is still illegible at small point sizes. Pointsize 9 is actually a bit better than 10 for CourierNew, but it's hardly readable compared to how it appears in Windows or on this website. (Code box)

So far what I'm left with is resizing, drawing the text huge, then resizing small again?

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T10:06:01-07:00
by fmw42
try other fonts. some fonts do not contain the font size you want or need and have to be rendered from other sizes. also you reference the PANGO page and are not using pango. see http://www.imagemagick.org/Usage/text/ for various methods of rendering text.

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T16:00:39-07:00
by BikeHelmet
fmw42 wrote:try other fonts. some fonts do not contain the font size you want or need and have to be rendered from other sizes. also you reference the PANGO page and are not using pango. see http://www.imagemagick.org/Usage/text/ for various methods of rendering text.
Thanks. :)

ImageMagick has so much documentation, I was getting lost in it all. I searched out how to draw text, but there's quite a few different methods - not all are ideal.

I'll read up on Pango.

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T17:10:06-07:00
by fmw42
By the way, you example code show and input image, webcam_640x360.jpg, but I see no sign of that in your white text on the thin black bar.

Try using a sans-serif font, also it generally works better with black text on white background.

Try these


convert logo: -undercolor black -fill white -font Arial -pointsize 10 -annotate +20+20 "www.SuperUglyWebcam.com/Webcam/" logo_tmp.png

convert logo: -fill black -font Arial -pointsize 10 -annotate +20+20 "www.SuperUglyWebcam.com/Webcam/" logo_tmp2.png

convert logo: \( -size 200x -background white -fill black -font Arial -pointsize 10 pango:"www.SuperUglyWebcam.com/Webcam/" \) \
-geometry +20+20 -compose over -composite logo_tmp3.png

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T17:15:17-07:00
by BikeHelmet
fmw42 wrote:By the way, you example code show and input image, webcam_640x360.jpg, but I see no sign of that in your white text on the thin black bar.
I cropped it. It didn't make sense to upload a 150KB image when cropped it's only 10KB. Some people still have slow internet, and the text was the only relevant part.

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T17:22:44-07:00
by fmw42
see my edited post above with the examples and comments about font and color (draw white background/undercolor and use black fill for a sans-serif font)

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-04-28T20:37:20-07:00
by BikeHelmet
Thanks, fmw42.

-annotate gives the same results as -draw, except that it takes longer to produce the result.

I haven't tested Pango yet, but I suspect it'll be the same. My choice of font is the main issue. Arial is far more legible than Courier New.

Well, thanks for the help! I may use Arial, or I may stick with supersampling. :)

Re: ImageMagick is rendering my tiny fonts really fat and ug

Posted: 2012-05-01T17:25:42-07:00
by anthony
BikeHelmet wrote:Getting rid of the -stroke option helped a little bit.

Adding +antialias got rid of the blurring, but the text is still illegible at small point sizes. Pointsize 9 is actually a bit better than 10 for CourierNew, but it's hardly readable compared to how it appears in Windows or on this website. (Code box)

So far what I'm left with is resizing, drawing the text huge, then resizing small again?

The stroke is making the font thick as you noticed.

But the thin fonts really do need to have anti-aliasing enabled so as to get good 'sub-pixel' handling of the font. Without it the font also becomes blocky and unreadable at low pointsizes.

Their are however bitmap fonts (pure black and white) that can be used, and some of these are in TTF font files, but only work at a very specific point size. Any other size and it is no longer a bitmap. The problem with may font finding sites is while they have such fonts, they don't provide the other information needed to make the font work as the author intended.

The above 'font text image' was part of a search for readable ultra tiny fonts, and was generated by code I added to the 'ttf image' reading mode of the TTF coder. However my changes to generate the above image was removed!! Arrrggghhhhhh! :roll:

Here is the results of that search (using fonts I had, or downloaded thinking they may do the job. This code was extracted from a 'text file thumbnailer' I wrote. The values 'font=' is the font name, and 'p=' the point size.

Code: Select all

#font=Arial                 p=6    # 6,9 good  7,8 not so good, proportional
#font=ArialN                p=7    #
#font=CourierNew            p=6    # very light, needs auto-level
#font=CourierNewB           p=6    # Best fixed width font at most sizes!
#font=PC                    p=7    # thinner and works better!
#font=BitstreamVeraSansMono p=6    # not very good
 font=LiberationMono        p=6    # quite good
#font=LucidaTypewriter      p=6    # quite good, 6 better
#font=LucidaTypewriterB     p=6    # bolder
#font=Terminal              p=6    # 6 good  8 nice (more line spacing)
#font=PixelMix              p=5    # 5 works 6 bad 7 overflows lines
#font=ETBT6001              p=6    # very clear monospaced (6pt ideal)
#font=CoolThreePixels       p=4    # a little too small (5pt ideal)
#font=7px4bus               p=7    # yuck 'a' (7pt ideal)
#font=Crystal               p=6    # very near proportional (not quite)
#font=Verdana               p=7    #\
#font=LucidaConsole         p=6    # > proportional fonts (clean when small)

#autolevel='-auto-level'  # for CourierNew, or PC
As you can see my current choice is LiberationMono at 6 point

The -auto-level is used to make the font clearer when I render it black on white. After rendering to a image I -compose multiply the generated 'font image' onto a background. To compose a white on black text onto a background use -compose screen.
See IM examples, Mathematical composition
http://www.imagemagick.org/Usage/compose/#multiply

I probably should write a script to display all the above fonts (and any other possibilities I may find) into the one image (with normal text index listing to the side). And a user selectable text 'test' string. But I never got to that stage, so my selection may not be 'the best'.

The other way, Which I often use for 'GIF diagram images' is to draw the image at a larger scale, then resize smaller. The font becomes small and sill readable, and the image results are finer. But it is unlikely to be better than finding a font that renders properly directly the smaller size.

Anyone else have a favourite 'readable tiny font'?


NOTE: photos are typically LARGE (pixel wise) so you can get 'photo quality' results when printed (at a cheap DIY photo lab) ASIDE: I don't think it is worth paying for personal photo printers myself.

Basically this means a 'tiny font' will typically disappear as a 'fuzzy line' along the bottom edge of the photo when displayed, or printed, unless you magnify that part of the image. That same information can also be stroed in the image file itself using profiles (EXIF, or more specialized IPTC profiles).
See Profiles
http://www.imagemagick.org/Usage/formats/#profiles

On the other hand 'tiny fonts' is a ON THE IMAGE so is not as simple to delete without cropping. But it is still easily removed.