Jump to content

[SOLVED] Gd text


Pezmc

Recommended Posts

I am using this script to generate changing text, how can I make the text always appear centered on the image?
[code=php:0]
<?php
$text = $_GET["text"];
$imgname = "images/bg.gif";

header("Content-type: image/png");

$im = imagecreatefromgif($imgname);

$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

$font = 'fonts/neuropolx.ttf';

//This text somehow needs to be centered
imagettftext($im, 10, 0, 15, 15, $grey, $font, $text);
imagettftext($im, 10, 0, 14, 14, $black, $font, $text);

imagepng($im);
imagedestroy($im);
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/30036-solved-gd-text/
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.