thinkphp图片等比例缩小

admin3年前thinkphp764
$image = \think\Image::open($filename);
        // 返回图片的宽度
        $width = $image->width();
        if($width > 600) {
            // 返回图片的高度
            $height = $image->height();
            // 返回图片的类型
            $type = $image->type();
            // 返回图片的mime类型
            $mime = $image->mime();
            // 返回图片的尺寸数组 0 图片宽度 1 图片高度
            $size = $image->size();

            $new_width = 600;
            $new_height = intval( $new_width*($height/$width) );
            $image->thumb($new_width, $new_height)->save($filename);
        }


相关文章

TP无法处理事务

1、InnoDB和MyISAM对事务的支持怎么样?InnoDB支持事务MyISAM不支持事务...

如何查看thinkphp当前版本号

如何查看thinkphp当前版本号

这篇文章主要介绍了如何查看thinkphp当前版本号,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。查看当前thinkphp版本有两种方...

eyoucms getInfo上传错误

endor('getid3.getid3');隐藏掉视频获取时长...

tp导出excel信息

public function studentsExport(){        set_time_limit (0);     ...

阿里云SDK如何在thinkphp5里调用

composor到vendor目录后项目内直接引用,譬如use AlibabaCloud\SDK\Ocrapi\V20210707\Ocrapi;use AlibabaCloud\Tea\Utils\...

thinkphp5 缓存 cache

http://www.17bigdata.com/book/thinkphp5/ZaXiang/HuanCun.html...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。