Jump to content

Anti Aliased Text, GD LIB


liamthebof

Recommended Posts

Hello PHPF,

I am having a problem with GDlib ini PHP. When using imagettftext(), I cannot seem to create crisp text, a form of smoothing/aliasing seems to be enabled. I have negated the color index, but the output is still too blurred to be useful for me in creating a crisp text. Anyone know how to make a work around to this?

<?php
$string = "A tester";
$width = 350;
$height = 19;
$img_handle = imageCreate($width,$height);
$bg_col = ImageColorAllocate($img_handle, 200,10,10);
$textcol = ImageColorAllocate($img_handle, 1, 1, 1);
$size = 10;
$font = "/visitor2.ttf";
$string_dim = imagettfbbox($size, 0, $font, $string);
$x = ($width / 2) - (($string_dim[4] - $string_dim[6]) / 2);
$y = 12;
Imagettftext($img_handle, $size, 0, $x, $y, -$textcol, $font, $string);
header('Content-type: image/jpg');
Imagejpeg($img_handle, "", 100);
?>

This is the php output:

97yr98wjri7oulir3ewp.jpeg

And here is the expected, anti-aliasing free image:

8pryaa6hgsqwyp1dk3ms.jpg

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/161044-anti-aliased-text-gd-lib/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.