2012-02-24 70 views
0

我正在使用PHP複製功能在上載到目錄後複製圖像。在複製之前有沒有辦法調整圖像大小?我需要調整它爲80x80在我的論壇中使用。複製前調整圖像大小?

這裏是如何我打電話給我的副本:

//lets move a copy to the img dir for the forum 
$avatar_tmp_file = 'forum/img/avatars/'.$_SESSION['forum_uid']. '.jpg'; 
copy($_FILES['file']['tmp_name'], $avatar_tmp_file); 

有什麼建議?

+0

http://php.net/manual/en/function.imagecopyresampled.php – j08691 2012-02-24 19:53:24

回答

3

是的,有一種方法可以這樣做。例如使用imagick。

$image=new Imagick(); 
$image->readImage($_FILES['file']['tmp_name']); 
$image->thumbnailImage(80,80); 
$image->writeImage($avatar_tmp_file); 
+0

指向我朝着正確的方向...謝謝! – Paul 2012-02-24 20:28:04