problem with generating an image

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
smatsri
Forum Newbie
Posts: 2
Joined: Thu Apr 15, 2004 4:56 am

problem with generating an image

Post by smatsri »

I use this code:

<?php
$height = 200;
$width = 200;
$im = imagecreate($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

imagefill($im, 0, 0, $black);
imageline($im, 0 ,0 ,$width, $height, $white);

header ("Content-type: image/png");
imagepng($im);

imagedestroy($im);


?>

and this is what i got:

‰PNG IHDRÈÈ—–<ÝPLTEÿÿÿUÂÓ~µIDATxœuϹ1ÀÐé|K£J $àï܇
RadixDev
Forum Commoner
Posts: 66
Joined: Sun Mar 14, 2004 11:27 am
Location: U.K.

Post by RadixDev »

Do you need the header() function? It looks to me as though the binary code for the image is being printed out... Take out the header() function and see what happens!

Check this out as well:-
http://uk.php.net/manual/en/function.imagepng.php
smatsri
Forum Newbie
Posts: 2
Joined: Thu Apr 15, 2004 4:56 am

Post by smatsri »

yeh fix the problem thx
Post Reply