好吧我真的新到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