php createimage不会将图像输出到浏览器

时间:2014-08-26 21:10:49

标签: php

你可以帮忙吗?

使用XAMPP我有localhost / drawrectangle.php包含以下不渲染图像的代码,我得到的是图像占位符,你能帮忙吗?

<?php

// Create a 200 x 200 image
$canvas = imagecreatetruecolor(200, 200);

// Allocate colors
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 132, 135, 28);

// Draw three rectangles each with its own color
imagerectangle($canvas, 50, 50, 150, 150, $pink);
imagerectangle($canvas, 45, 60, 120, 100, $white);
imagerectangle($canvas, 100, 120, 75, 160, $green);

// Output and free from memory
header('Content-Type: image/jpeg');

imagejpeg($canvas);
imagedestroy($canvas);

?>

0 个答案:

没有答案