/**
* @param $source 源图片地址
* @param $dest 目标图片地址
* @param $percent 缩放比例
**/
function resizeImage($source, $dest, $percent)
{
list($width, $height, $type, $attr) = getimagesize($source);
$type = image_type_to_extension($type, false);
$dst_width = $width * $percent;
$dst_height = $height * $percent;
$dst = imagecreatetruecolor($dst_width, $dst_height);
$fun = 'imagecreatefrom' . $type;
$src = $fun($source);
imagecopyresampled($dst, $src, 0, 0,0,0, $dst_width, $dst_height, $width, $height);
$fun = 'image' . $type;
$fun($dst, $dest);
}
PHP实现图片压缩
最新推荐文章于 2023-03-13 23:00:22 发布