好吧我真的新到PHP,我發現下面的下面的腳本。但我不知道如何使用它我想知道我在哪裏把鏈接的圖像例如images/photo.jpg爲了讓我開始學習這個腳本感謝。PHP圖像調整大小腳本?
這是代碼。
<?php
function resizeImage($originalImage,$toWidth,$toHeight){
// Get the original geometry and calculate scales
list($width, $height) = getimagesize($originalImage);
$xscale=$width/$toWidth;
$yscale=$height/$toHeight;
// Recalculate new size with default ratio
if ($yscale>$xscale){
$new_width = round($width * (1/$yscale));
$new_height = round($height * (1/$yscale));
}
else {
$new_width = round($width * (1/$xscale));
$new_height = round($height * (1/$xscale));
}
// Resize the original image
$imageResized = imagecreatetruecolor($new_width, $new_height);
$imageTmp = imagecreatefromjpeg ($originalImage);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
return $imageResized;
}
?>
我想做更多,然後只保存一個JPG圖像。 – PeAk 2009-11-12 01:54:57
是的,我明白了,但代碼丟失保存或顯示操作的圖片! – powtac 2009-11-12 03:40:26
imagejpeg($ imageResized); 改變的圖像返回到瀏覽器! – powtac 2009-11-12 03:41:08