thinkphp图片等比例缩小

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


相关文章

token放在请求头Authorization 结果thinkphp中没有Authorization

token放在请求头Authorization 结果thinkphp中没有Authorization

告诉后端我给你发送的请求数类型 是json字符串,如果是默认可以是json对象Content-Type':application/json现在连接token可以放在cookie或者请求头上给我...

thinkphp5 缓存 cache

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

thinkphp 项目报错No input file specified.

1提示:“No input file specified.”原因在于使用的PHP5.6是fast_cgi模式,而在某些情况下,不能正确识别path_info所造成的错误。默认的.htaccess里面的...

如何查看thinkphp当前版本号

如何查看thinkphp当前版本号

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

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

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

thinkphp分页paginate获取可以foreach的数据

public function index(){    $goods_name = I('goods_name&...

发表评论    

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