我看了幾個其他類似的問題,但不幸的是他們都沒有幫助解決我遇到的問題。Xampp imagecreatefrompng()產生破碎的圖像
這是腳本。
<?php
// returns a PNG graph from the $_GET['per'] variable
$per = imagecreate(302,7);
$background = imagecolorallocate($per, 0xFF, 0xFF, 0xFF);
$foreground = imagecolorallocate($per, 0x00, 0x8A, 0x01);
$border = imagecolorallocate($per, 0x99, 0x99, 0x99);
if ($_GET['per'] > 0)
{
$grad = imagecreatefrompng("images/grad.png");
$per2 = imagecopy($per, $grad, 1, 1, 0, 0, ($_GET['per'] * 3), 5);
imagerectangle($per, 0, 0, 301, 6, $border);
}
header("Content-type: image/png");
imagepng($per,NULL,5);
?>
我檢查了GD支持,所以我不確定是什麼問題。如果我只是建立一個簡單的酒吧,而不使用圖像,它會正常工作,但是當我嘗試用圖像構建時,它只顯示一張破碎圖像的圖片。
error_log中顯示任何PHP錯誤? – drew010
不,我有錯誤報告設置給所有人,我也沒有得到任何通知。 – kira423
您是否通過檢查$ per2是否正確來驗證imagecopy是否正在運行? – ernie