2011-02-28 49 views
0

我有這樣的腳本:PHP GD2略圖創建腳本問題

function createThumb($source, $thumb_width=100) 
     { 
    $fl = dirname($source).'<br>'; 
    $new_name = 'thumb_'.basename($source); 
    $img = imagecreatefromjpeg($source); 
    $width = imagesx($img); 
    $height = imagesy($img); 
    $new_width = $thumb_width; 
    $new_heght = floor($height * ($thumb_width/$width)); 
    $tmp_name = imagecreatetruecolor($new_width, $new_heght); 
    imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_heght, $width, $height); 
     imagejpeg($tmp_img, $fl.DIRECTORY_SEPARATOR.$new_name); 
     } 

所有數據都工作正常。我回應每一步到imagecopyresized我得到這個警告。

警告:imagecopyresized():提供的參數不是在/www/mdkbg.com/keasport/root/admin/parsing_vars.php5有效的圖像資源上線41

可能是什麼問題呢?我已將文件夾權限更改爲755,並使用php5文件管道。

回答

0
$tmp_name = imagecreatetruecolor($new_width, $new_heght); 

應改爲:

$tmp_img = imagecreatetruecolor($new_width, $new_heght); 
+0

我沒有看到錯誤,但這個工作。我只是有幻覺,真的沒有看到區別:) – Victor 2011-02-28 13:47:06

+0

您將新圖像分配給變量'$ tmp_name',但是當您嘗試使用它時,您將其稱爲'$ tmp_img'。 – qbert220 2011-02-28 13:49:15

+0

aaaa現在我明白了。非常感謝你 – Victor 2011-02-28 13:51:25