Page 1 of 1

create image from string error

Posted: Mon Jul 25, 2005 7:59 pm
by br5dy
I'm trying to create a simple image from an e-mail address, therefore eliminating the possibility of spybots gathering the address.

this is what i have:

Code: Select all

$string = 'test';
$im    = imagecreatefromgif("images/email.gif");
$orange = imagecolorallocate($im, 220, 210, 60);
$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagegif($im);
imagedestroy($im);
email.gif is just a white box suitable for an e-mail address

I also have the header set as this:

Code: Select all

<meta Content-type='image/gif'>
I have tried including it in the PHP script and it makes no difference.

However, here's my problem. When I check the PHP page, this is the error I get. It's not really even an error.

Code: Select all

GIF89a† €ÜÒ<ÿÿÿ!ù,† ,Œ

Posted: Mon Jul 25, 2005 8:58 pm
by timvw
Actually, the <meta> tag can only be used in html..

You should use http://www.php.net/header instead:

Code: Select all

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

Posted: Tue Jul 26, 2005 8:18 pm
by br5dy
I tried it, and php return no error, but nothing happens. I just get a blank page, no output, or anything.

Posted: Tue Jul 26, 2005 8:28 pm
by timvw
You can prepend to your code:

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);
If you output the header, generate the image and output the GIF89a† €ÜÒ.. It should work...

Posted: Tue Jul 26, 2005 11:11 pm
by br5dy
Thanks. Turns out I accidently had my font size too big and the gif wouldn't hold it.....eh....heh... :roll: sorry about that.

Posted: Tue Jul 26, 2005 11:24 pm
by theda
On behalf of this forum, I believe you are forgiven... Unless Burrito owes you a lunch.