Strange problems with Imagepng
The code below, it is strange to change imagepng ($im) to Imagepng ($im, "kk.png") can get the picture but the direct output to the browser is not displayed, has been a red fork, this code on another machine can run normally. Is my PHP configuration problem?
Header ("Content-type:image/png");
Srand (Double) microtime () *1000000);
$login _check_number=strval (rand ("11111", "99999"));
$session->setmember ("Loginchecknumber", $login _check_number);
$im = Imagecreate (50,20) or Die ("Cannot Initialize new GD image Stream");
$black = Imagecolorallocate ($im, 9,142,204);
$foreColor = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
Imageline ($im, 1, 1, $black);
Imagearc ($im, Max, N, a, A, a, $white);
Imagestring ($im, 5, 7, 3, $login _check_number, $white);
for ($i =0; $i < $i + +)//Add interfering pixels
{
Imagesetpixel ($im, Rand ()%50, Rand ()%50, $foreColor);
}
Imagepng ($im);
Imagedestroy ($im);
?>
------Solution--------------------
discuss
Reference:
Reference:
GD Library does not open words imagepng ($im, "kk.png") can generate Kk.png file?
It's supposed to be about the browser.
Replace the first sentence with a trial header ("Content-type:image/x-png");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.