/**
* 图片放大到750
* Created by PhpStorm.
* User: EricPan
* Date: 2020/8/16
* Time: 18:32
*/
public function img750()
{
$userName1 = "源图片路径";
$userName = " 生成图片存储路径";
$bgResource = imagecreatefromstring(file_get_contents($userName1));
// 源图片尺寸
$s_w = imagesx($bgResource);
$s_h = imagesy($bgResource);
//获取图片尺寸
//生成新的图片尺寸
$new_w=750;
$new_h=750;
//创建新的图像
$im2=imagecreatetruecolor($new_w, $new_h);
//拷贝资源图片到新图像
imagecopyresampled($im2, $bgResource, 0, 0, 0, 0, $new_w, $new_h, $s_w, $s_h);
// 存储新图片
imagepng($im2,$userName);
// 释放内存
imagedestroy($bgResource);
// 释放内存
imagedestroy($im2);
}
PHP图片尺寸调整(全填充,没有黑底)
最新推荐文章于 2021-04-01 13:15:59 发布