打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
PHP 调整图像尺寸
/********************** *@filename - path to the image *@tmpname - temporary path to thumbnail *@xmax - max width *@ymax - max height */ 
function resize_image($filename$tmpname$xmax$ymax) { 
    $ext explode("."$filename); 
    $ext $ext[count($ext)-1]; 
    if($ext == "jpg" || $ext == "jpeg"$im = imagecreatefromjpeg($tmpname); 
    elseif($ext == "png"$im = imagecreatefrompng($tmpname); 
    elseif($ext == "gif"$im = imagecreatefromgif($tmpname); 
     
    $x = imagesx($im); 
    $y = imagesy($im); 
    if($x <= $xmax && $y <= $ymaxreturn $im
    if($x >= $y) { 
        $newx $xmax
        $newy $newx $y $x
    }  else 
        $newy $ymax$newx $x $y $newy
    }
    $im2 = imagecreatetruecolor($newx$newy); 
    imagecopyresized($im2$im, 0, 0, 0, 0, 
    floor($newx), floor($newy), $x$y); 
    return $im2;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Python验证码自动识别
厨房电器30
复现《nature communications》图表:ggplot添加图片/示意图元素
使用RetinaNet构建的人脸口罩探测器
3.1.4 函数分布的快速绘图
y = mapminmax('apply',x,ps)中各个参数是什么意思呢?
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服