create image from string error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

create image from string error

Post 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† €ÜÒ<ÿÿÿ!ù,† ,Œ
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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');
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

Post by br5dy »

I tried it, and php return no error, but nothing happens. I just get a blank page, no output, or anything.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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...
br5dy
Forum Newbie
Posts: 22
Joined: Sat Jul 23, 2005 2:52 pm

Post 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.
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post by theda »

On behalf of this forum, I believe you are forgiven... Unless Burrito owes you a lunch.
Post Reply