thinkphp图片等比例缩小

admin3年前thinkphp678
$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);
        }


相关文章

thinkphp分页,数字页+上下页+跳转+每页数据下拉

<?php namespace Think; class Page{     public $firstRow;&...

thinkphp5 缓存 cache

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

thinkphp5简单的分页

//获取相关文章    public function getSearchArticle() {        if(iS_AJAX) {&...

Thinkphp5+Redis实现商品秒杀代码实例讲解

https://www.gongshengyun.cn/yunying/forum.php?mod=viewthread&tid=20844...

阿里云SDK如何在thinkphp5里调用

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

eyoucms getInfo上传错误

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

发表评论    

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