Page 1 of 1

How to avoid smaller annotated text break-up?

Posted: 2009-06-13T16:14:46-07:00
by hightman
Hello, this problem had puzzled me much long time.

When I annotate some small text (equal to or samller than 12px) on the picture, it looks very ugly and seems break up when I trun off the antialias effect.

Let's look following three pictures(I drew these pictures use PHP MagickWand extension & PHP-Gd2 extension)

1. Drew use ImageMagick-6.5.3-6 without antialias: Image
2. Drew use ImageMagick-6.5.3-6 with antialias: Image
3. Drew use PHP-GD2 (the text looks very clear): Image

How can I deal with this problem? I think this is not a FONT problem, maybe it can be fixed by modifing code on magick/annotate.c, but I cann't resolved it...

--

I generate the two images use these Command, used the same font file for GD.

Code: Select all

convert  -size 60x20 xc:lightblue -font simsun.ttc  -pointsize 12 -fill black +antialias -annotate +3+15 "试试看" test1.jpg
convert  -size 60x20 xc:lightblue -font simsun.ttc  -pointsize 12 -fill black -antialias -annotate +3+15 "试试看" test2.jpg
The TTC Font file can be downloaded from here: http://www.czxiu.com/~hightman/simsun.tar.bz2(about 5.3MB)

The text annotated on the image was break-up, It seems these error was fixed in GD-lib along with a special algorithm.

gd used in PHP, php script run at the same machine ImageMagick installed, they are using same FreeType-2.3.7

Code: Select all

<?php
$im = imagecreate(60, 20);
$bg = ImageColorAllocate($im, 255, 255, 255);
$fg = imagecolorallocate($im, 0, 0, 0);

ImageFill($im, 0, 0, $bg);
ImageFTText($im, 9, 0, 3, 15, $fg, "simsun.ttc", "试试看");

header("Content-Type: image/jpeg");
ImagePng($im);
?>
--

The problem code maybe here, (magick/annotate.c), but I dont know how to fix or adjust them... :(

...
1291 fill_opacity=(MagickRealType) (*p)/255.0;
1292 if (draw_info->text_antialias == MagickFalse)
1293 fill_opacity=fill_opacity > 0.5 ? 1.0 : 0.0;

1294 if (active == MagickFalse)
1295 q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
1296 exception);
...

Re: How to avoid smaller annotated text break-up?

Posted: 2009-06-13T19:00:54-07:00
by magick
Freetype supports a FT_LOAD_MONOCHROME rendering mode which ImageMagick does not use. We found it does a better job in some cases and in other cases, ImageMagick does a better job. We will revisit the issue in the near future.

Re: How to avoid smaller annotated text break-up?

Posted: 2009-06-13T21:24:41-07:00
by hightman
magick wrote:Freetype supports a FT_LOAD_MONOCHROME rendering mode which ImageMagick does not use. We found it does a better job in some cases and in other cases, ImageMagick does a better job. We will revisit the issue in the near future.
Oh, thanks you very much, I strongly thirst for this feature for a long time.
I hope it can be added to IM with a compile option or draw settings option, even if give a code patch in a near future.