FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP image





krazycapital
I'm trying to make it so that I don't have to make a new image for each page, and use php to generate it instead. I have the base image, but I need to add text to it. It keeps giving me the same error message:
Error wrote:
The image “http://webbie.zach.frih.net/addtitle.php?title=Webbie.com&left=21&page=&pleft=170” cannot be displayed, because it contains errors.

I am pretty sure this is because it can't find the font files. I have tried multiple paths and stuff like that, but it still won't work. I know it shouldn't be my script because I have it working on my computer. Or does it have to be in a certain file?
Here is the code (if you need it) I cut this from when I had it in the same file:
Code:
<?php
$im = imageCreateFromPNG("images/tileheader.png") ;
header('Content-type: image/png');
// Get Font
$font = 'obloquyo.ttf';
$font2 = 'BoringLesson.ttf';
$font3 = '04B_03__.TTF';
//Colors
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 128, 128, 128);
//The text
$text = $_GET[title];
$tagline = "Welcome to your web!";
$pagetag = $_GET[page];
//Adds text
$shad = $_GET[left]+3;
$lefttag = 10;
$tagshad = $lefttag+3;
$pleft = $_GET[pleft];

imagettftext($im, 12, 0, $pleft, 140, $black, $font3, $pagetag);

imagettftext($im, 18, 0, $tagshad, 28, $gray, $font, $tagline);
imagettftext($im, 18, 0, $lefttag, 25, $black, $font, $tagline);

imagettftext($im, 25, 0, $shad, 88, $gray, $font2, $text);
imagettftext($im, 25, 0, $_GET[left], 85, $black, $font2, $text);

//Makes image
imagePNG($im);
imageDestroy($im);
?>

Thanks in advance,
Zach
PS: If this is against the rules, please tell me so I can remove it immediately.
Daniel15
Look at the output of the http://webbie.zach.frih.net/addtitle.php?title=Webbie.com&left=21&page=&pleft=170 page:

Quote:
<br />
<b>Fatal error</b>: Call to undefined function: imagettftext() in <b>/home/krazycap/domains/zach.frih.net/public_html/webbie/addtitle.php</b> on line <b>21</b><br />


That means that the imagettftext() function doesn't exist. According to the PHP help page for that function, it needs both the GD library, and the FreeType library. I don't believe that FriHost has the FreeType library installed.
krazycapital
I get a completely different error message, posted above. Is there a way to actually create that function on your own, like
Code:
function imagettftext($var,$var,$var,$var,$var,$var,$var,$var)
{ code here }

or to get it from the freetype library? I have it on my computer so if somebody knows where it is, I might be able to get it from there too. Thanks.
Or if bondings reads this, would it be possible to install the freetype library?
Daniel15
To see the error I got, go directly to http://webbie.zach.frih.net/addtitle.php?title=Webbie.com&left=21&page=&pleft=170 and then click 'View Source' on that page. Or, you can comment the header('Content-type: image/png'); line (so it becomes:
Code:
//header('Content-type: image/png');
) and then you'll see the error

Unfortunately, the only way to get the FreeType library is for Bondings to install it.
Related topics
E-Cards with PHP & MySQL
PHP Image Upload (MySQL/Folder)
PHP Image suddenly doesn't work?
php image exif functions
mysql/php help please
PHP image uploads with progress bar AND resizing? [Resolved]
let me tell you... this is not an image! it's HTML code!
Transparent background image
PHP Image Questions
PHP Image functions
Opening any image with PHP. Couldn't find anywhere.
Pls help, onmouseover popup image frm database
xMPACT! PHP Image Viewer 1.0
PhP Image gallery?
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.