我有一個PHP腳本如下重新大小的圖像文件;黑色結果圖像的問題 - PHP
$file = "test.bmp";
$ext = pathinfo($file, PATHINFO_EXTENSION);
$info = pathinfo($file);
$file_name = basename($file,'.'.$info['extension']);
$thumbname = "thumb/".$file_name.".".$ext;
$maxh = 200;
$maxw = 200;
$quality = 100;
list($width,$height)=getimagesize($file);
$src = imagecreatefromwbmp($file);
$tmp = imagecreatetruecolor($maxw,$maxh);
imagecopyresampled($tmp,$src,0,0,0,0,200,200,$width,$height);
imagejpeg($tmp,$thumbname,$quality);
imagedestroy($tmp);
腳本是假設一個Windows位圖圖像尺寸調整到200x200的縮略圖。但是,我得到一個黑色的200x200圖像。我在Windows PC中使用Apache與Apache。任何人有解決方案或修復?預先
只是檢查'$ src'使用它之前。也許它是'FALSE'? – hakre 2011-06-15 15:54:03
@hakre,我應該更改/替換 – 2011-06-15 15:55:51
在這裏的示例代碼中查找'if(!$ im)':http://php.net/manual/en/function.imagecreatefromwbmp.php – hakre 2011-06-15 15:59:02