我把代碼從php.netImagecreatefrompng問題
function LoadPNG($imgname)
{
$im = @imagecreatefrompng($imgname);
if(!$im)
{
$im = imagecreatetruecolor(150, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 1, 5, 5, 'Error loading ' . $imgname, $tc);
}
return $im;
}
header('Content-Type: image/png');
$path = './upload/xxx.png';
$img = LoadPNG($path);
imagepng($img);
imagedestroy($img);
,我在瀏覽器中有消息,頁面沒有加載:收到 無法加載網頁
沒有數據,因爲服務器未發送任何數據。 以下是一些建議: 稍後重新加載此網頁。 錯誤324(net :: ERR_EMPTY_RESPONSE):服務器關閉連接而不發送任何數據。
但是,如果我將imagecreatefrompng更改爲imagecreatefromjpeg,imagepng到imagejpeg和路徑到jpeg文件。或寫incorect文件我有錯誤圖像(imagestring) - 它工作正常...
有多大(分辨率)是你正在處理('/上傳/ xxx.png')PNG圖像? – Buggabill
Buggabill發佈了一個很好的答案,可以幫助您調試您的問題。但在另一個說明中,php.net上發佈的示例並不是簡單地使用和準確使用。它們是用法*示例*,應該用於*幫助*您編寫自己的實現。 – adlawson