Page 1 of 1

problem with generating an image

Posted: Thu Apr 15, 2004 4:56 am
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 $àï܇

Posted: Thu Apr 15, 2004 5:06 am
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

Posted: Thu Apr 15, 2004 5:52 am
by smatsri
yeh fix the problem thx