Page 1 of 1

How can I get the same annotation text effect as GD-lib?

Posted: 2009-06-13T13:11:50-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...

Re: How can I get the same annotation text effect as GD-lib?

Posted: 2009-06-13T14:52:14-07:00
by fmw42
hightman wrote: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...

Post your exact IM commands!

What IM method: label:, caption:, -annotate or -draw? see http://www.imagemagick.org/Usage/text/

Also do you know that GD is using the exact same font set (not just font name) as IM?

Re: How can I get the same annotation text effect as GD-lib?

Posted: 2009-06-13T15:54:07-07:00
by hightman
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);
?>

Re: How can I get the same annotation text effect as GD-lib?

Posted: 2009-06-13T16:11:49-07:00
by hightman
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 can I get the same annotation text effect as GD-lib?

Posted: 2009-06-13T16:50:29-07:00
by fmw42
what version of IM are you using? If it is old, then upgrade and see if it works.


also see notes about unicode (utf-8) at http://www.imagemagick.org/Usage/text/#unicode

also add -strokewidth 1 to your command with and without +antialias

not sure if +antialias works with -annotate?

Re: How can I get the same annotation text effect as GD-lib?

Posted: 2009-06-13T21:13:17-07:00
by hightman
fmw42 wrote:what version of IM are you using? If it is old, then upgrade and see if it works.


also see notes about unicode (utf-8) at http://www.imagemagick.org/Usage/text/#unicode

also add -strokewidth 1 to your command with and without +antialias

not sure if +antialias works with -annotate?
The version of my IM is the newest (6.5.3-6) ...
All your advice I had tried, but there wasn't any effects, because this is a clearType problem??

Re: How can I get the same annotation text effect as GD-lib?

Posted: 2009-06-14T06:28:28-07:00
by anthony
This thread was transferred to developers forum (not by me).
viewtopic.php?f=2&t=13988
Interested parties to continue discussion there.