/*
* 将图片等比例缩放
* dest_path 源图片地址
*/
function imageUpdateSize( dest_path)
{
//将图片等比例缩放
path.md5(width, dest_path);
//缩放比例
width,3);
width * n_h = per;
//1.创建画布
$new = imagecreatetruecolor($n_w, $n_h);
$img = imagecreatefrompng($dest_path);
//2.上色
$color=imagecolorallocate($new,255,255,255);
//3.设置透明
imagecolortransparent($new,$color);
imagefill($new,0,0,$color);
//copy部分图像并调整
imagecopyresized($new, $img,0, 0,0, 0,$n_w, $n_h, $width, $height);
//图像输出新图片、另存为
imagepng($new, $new_path);
imagedestroy($new);
imagedestroy($img);
return $new_path;
}
网友评论