我有一个网站,我想上传一张图片并调整它的大小,因为我必须将它放入具有特定尺寸的 div 中。
例如,我的最大宽度为 200 像素,最大高度为 100 像素
我想上传图像并检查宽度和高度,如果它们大于最大宽度或最大高度,我想找到图像的大小以保持在该 div 内。
如何按比例调整图像的大小?我只想在我的 div 200px*100px 的基础上找到新的宽度和新的高度
这是我的脚本:
if(move_uploaded_file($tmp, $path.$actual_image_name))
{
list($width, $height, $type, $attr) = getimagesize($tmp);
if($width>200){
//too large I want to resize
}
if($height>100){
//too height I want to resize
}
echo(base_url().$path.$actual_image_name);
}