thinkphp图片压缩-composer-Intervention-Image-ImageManagerStatic
2021-03-28 22:26
                         标签:基础上   tin   输出   插件   fun   cti   names   ==   and    先抛出composer插件 我这段代码实现的是在原来的基础上直接覆盖,相当于无痕压缩。 有输出另外需求的可以改变save路径 附上官方文档:http://image.intervention.io/api/save thinkphp图片压缩-composer-Intervention-Image-ImageManagerStatic 标签:基础上   tin   输出   插件   fun   cti   names   ==   and    原文地址:https://www.cnblogs.com/chenliuxiao/p/12614494.htmlcomposer require intervention/image
use Intervention\Image\ImageManagerStatic as Image;
public function youhua()
    {
        $hostdir=ROOT_PATH . ‘public‘ . DS .‘yh‘; //要读取的文件夹
        $filesnames = scandir($hostdir); 
        foreach ($filesnames as $name) {
            if($name==‘.‘||$name==‘..‘){
                continue;
            }else{
                $aurl= ROOT_PATH . ‘public‘ . DS .‘yh‘  . DS . $name;
                $img = Image::make($aurl);//打开的路径
                $img->resize(200, 266);//定制宽高
                $img->save($aurl);//保存
                echo $aurl . "
"; //输出
            }
        }
    }
文章标题:thinkphp图片压缩-composer-Intervention-Image-ImageManagerStatic
文章链接:http://soscw.com/index.php/essay/69238.html