Я создаю прозрачный gif с текстом с библиотекой gd, но качество вывода текста не очень хорошо. Есть ли у кого-нибудь идея, как я могу улучшить качество?лучшее качество изображения для gif с библиотекой gd в PHP
Вот код:
$req = explode('|', $_REQUEST['r']);
$text = $req[0];
header ("Content-type: image/gif");
$font = getFont($req[2]);
$font_size = $req[1];
$tmpcolor = getColor($req[3]);
[email protected]('gfx/transparent.gif');
$width = imagesx($tmp_image);
$height = imagesy($tmp_image);
//calculate the new width/height
$tmp = imagettfbbox($font_size,0,$font,$text);
$new_width = $tmp[2]+10;
$new_height = $font_size+5;
$new_image = imagecreate($new_width,$new_height);
ImageCopyResized($new_image, $tmp_image,0,0,0,0, $new_width, $new_height, $width, $height);
$black = ImageColorAllocate($new_image, 0, 0,0);
$trans = ImageColortransparent($new_image,$black);
$color = ImageColorAllocate($new_image, trim($tmpcolor[0]), trim($tmpcolor[1]), trim($tmpcolor[2]));
imagettftext($new_image, $font_size, 0, 0, $font_size, $color, $font, $text);
//Grab new image
imagegif($new_image);
imagedestroy($new_image);
imagedestroy($tmp_image);
Вот результат:
Спасибо
imagecreatetruecolor останавливает мой вывод, и он освобождает текст. :( – apple
@apple он не должен этого делать. Поверните отчет об ошибках: 'error_reporting (E_ALL);', чтобы посмотреть, в чем проблема. –