我正在尝试调整照片的大小,我从PHP的官方网站上获得了一个函数。这是一个功能,调整大小的照片,而不失去他们的比率。
public function ImageResize($filename, $max_width,$max_height){
list($orig_width,$orig_height) = getimagesize($filename);
$width = $orig_width;
$height = $orig_height;
#c'est la photo est grande.
if($height > $max_height){
$width = ($max_height/$height) * $width;
$height = $max_height;
}
#c'est la photo est larage
if($width > $max_width){
$height = ($max_width/$width) * $height;
$width = $max_width;
}
$image_p = imagecreatetruecolor($width,$height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0,
$width, $height, $orig_width, $orig_height);
return $image_p;
}这个函数应该发送给我一张图片,问题是:还原后的图像是自动写到磁盘上的,还是我需要做更多的处理才能在旧图片和新图片之间进行更改。
发布于 2016-04-28 10:08:11
在保存图像之前,图像只能在变量$image_p中可用。如下所示:
imagejpeg($image_p, 'your_image_in_disk.jpg');https://stackoverflow.com/questions/36911307
复制相似问题