By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

PHPGD

P: n/a
I am trying to overlay text in a ttf font over an already existing
image. From what I can see it should work but I'm not sure what the
problem is.

<?
Header ("Content-type: image/png");
putenv('GDFONTPATH=' . realpath('.'));
$font = 'j';

$img_handle = imageCreateFromPNG("stupid.png");
$color = ImageColorAllocate ($img_handle, 100, 100, 100);
$wrong = $_GET['wrong'];
$right = $_GET['right'];

imagettftext($img_handle, 3, 10, 49, $font, $color, "$wrong is
$right!!");
ImagePng ($img_handle);
ImageDestroy ($img_handle);
?>

It says the image can not be displayed because it contains errors.

Thanks,
Ryan
Oct 1 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 1 Oct, 01:13, BryanA <syv.r...@gmail.comwrote:
I am trying to overlay text in a ttf font over an already existing
image. From what I can see it should work but I'm not sure what the
problem is.

<?
Header ("Content-type: image/png");
putenv('GDFONTPATH=' . realpath('.'));
$font = 'j';

$img_handle = imageCreateFromPNG("stupid.png");
$color = ImageColorAllocate ($img_handle, 100, 100, 100);
$wrong = $_GET['wrong'];
$right = $_GET['right'];

imagettftext($img_handle, 3, 10, 49, $font, $color, "$wrong is
$right!!");
ImagePng ($img_handle);

ImageDestroy ($img_handle);
?>

It says the image can not be displayed because it contains errors.
Try losing the content type header and see what you get.

Or read your logs.

C.
Oct 1 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.