Jump to content

Recommended Posts

Thanks for helping.  I'm having trouble with the following:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
$image = imagecreatefrompng("images/esuom.png");
if(!$image)
die("Error loading image.");
$text_color = imagecolorallocate($image, 13, 37, 62); 
$x = 100;
$y = 30;
$fontsize = 12;
$fontfile = "fonts/VAG Rounded BT.ttf";
$text = "Hello World!";

imagettftext($image, $fontsize, 0, $x, $y, $text_color, $fontfile, $text);

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

imagepng($image);
imagedestroy($image);
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

 

I have it uploaded here: http://imobworld.com/dynamicsigs/

Does anyone know what's wrong?

 

Thanks,

Gil

Link to comment
https://forums.phpfreaks.com/topic/161843-solved-trouble-writing-text-to-an-image/
Share on other sites

first ofall, when you start sending text, you send the headers, so right off the bat, your script isn't going to work with all that html surrounding your php code

 

so first step up is a big one.. get rid of the html..

 

<?php
$image = imagecreatefrompng("images/esuom.png");
if(!$image)
die("Error loading image.");
$text_color = imagecolorallocate($image, 13, 37, 62); 
$x = 100;
$y = 30;
$fontsize = 12;
$fontfile = "fonts/VAG Rounded BT.ttf";
$text = "Hello World!";

imagettftext($image, $fontsize, 0, $x, $y, $text_color, $fontfile, $text);

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

imagepng($image);
imagedestroy($image);
?>

 

oh.. and nice font name :P VAG Rounded :P

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.