FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Please help images again.

 


The-Master
I have reasearched this a bit but it does not work Crying or Very sad

Code:
<?php

header("Content-type: image/gif");
$string = $_GET['text'];
$im    = imagecreatefrompng("http://www.dougie.frih.net/images/files.gif");
$orange = imagecolorallocate($im, 220, 210, 60);
$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);

?>

Why does it not work and please don't just say, "That is Easy." Laughing
hexkid
The-Master wrote:
Why does it not work


I've taken the liberty to paste your code unquoted and out of code block so that the reds can be seen

<?php

header("Content-type: image/gif"); ### A
$string = $_GET['text'];
$im = imagecreatefrompng("http://www.dougie.frih.net/images/files.gif"); ### B
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im); ### C
imagedestroy($im);

?>

The first line says you're about to output a gif image ... but you end up outputting a png image (lines A and C).
You're also trying to read a gif image as if it was a png (line B).
The-Master
Thanks very much. lol. That was a school boy error!
hexkid
One more thing ...

You read the template image from the webserver
Code:
$im = imagecreatefrompng("http://www.dougie.frih.net/images/files.gif");

I very much prefer to read it directly from the file system
Code:
$im = imagecreatefrompng('/home/dougie/domains/dougie.frih.net/images/files.gif');
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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