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


Could someone help me with this image code





The-Master
Code:
<?php
header("Content-type: image/png");
$img_bg_loc = 'http://www.dougie.frih.net/images/Testing.PNG';
list($x, $y, $maxwidth) = array(0, 0, 0);
$fontsize = 18;
if(@$_GET['fontsize']) {
   $fontsize = $_GET['fontsize'];
}
$font = 'Halo.ttf';
$text = @$_GET['text'];

$im = imagecreatefrompng($img_bg_loc);;
$yellow = imagecolorallocate($im, 225, 225, 225);

$img_w = imagesx($im);
$px = ($img_w - 1 * strlen($text)) / 3;

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

imagefttext($im, $fontsize, 0, $x, $y, $yellow, $font, $text);

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


What I want is it to appear with the font Halo.ttf which is in the same folder to appear over the image with the text being after the web address.
jabapyth
your having a problem i presume?
hexkid
Try this, just so that you can see what's happening.
Code:
<?php
error_reporting(E_ALL);
#header("Content-type: image/jpg");
header("Content-type: text/plain");
// ...
?>
The-Master
I get This error
Code:
<br />
<b>Fatal error</b>:  Call to undefined function:  imagecreatefromjpg() in <b>/home/themaste/domains/dougie.frih.net/public_html/PHP/Uploaded Font 2.php</b> on line <b>20</b><br />
hexkid
The-Master wrote:
I get This error
Code:
<br />
<b>Fatal error</b>:  Call to undefined function:  imagecreatefromjpg() in <b>/home/themaste/domains/dougie.frih.net/public_html/PHP/Uploaded Font 2.php</b> on line <b>20</b><br />


Well ... that function is not part of standard PHP.
Verify for yourself: type php.net/imagecreatefromjpg in the address bar and press enter.
The-Master
OK I have managed to sort out all the errors so that the image appears using the updated code on my firs post. I want to use a font in the folder that my script is in, but whenever I put in the web address with ?text=hello Nothing happens to the image. Have I done something wrong?
hexkid
The-Master wrote:
OK I have managed to sort out all the errors so that the image appears using the updated code on my firs post. I want to use a font in the folder that my script is in, but whenever I put in the web address with ?text=hello Nothing happens to the image. Have I done something wrong?


The coordinates for the text in imagefttext() probably are not what you are expecting.

When you set $x = 0, the text will be written "above" the image.
Your source image is 1253 x 1035 pixels. I'd start with $x = 1253/2; and $y = 1035/2; and adjust from there.

Code:
<?php
// ...
$x = 1253/2;
$y = 1035/2;
imagefttext($im, $fontsize, 0, $x, $y, $yellow, $font, $text);
// ...
?>
Related topics
Can someone help me ? Com domain setup?
Programming Help & Support Guidelines
can someone help me?
phbb skin
CAN SOMEONE HELP? I DON'T UN DERSTAND HOW TO UPLOAD WEBSITE!
css background
Can someone help me??
HELP with Javascript!
Ftp uploading help
Help with Css to insert image
I need a solution for gallery in mootools and upload image
random image code?
How to make this code simple?
i am having problems with this php code.... can someone help
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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