很多时候 我们需要将图片进行压缩 这里简单介绍一下think-image 扩展进行图片压缩
安装comoposer 此处不在赘述 自行百度
然后再其目录下 允许命令 :
composer require topthink/think-image
新建一个index.php 文件
touch index.php
然后 进入 index.php 如下
<?php
require './vendor/autoload.php';
$img = "./image.png"; //需要压缩的图片路径地址
$image = \think\Image::open($img);
$type = $image->type();
$path = "./new_img.png"; //新的图片路径地址
$image->save($path,$type,40);
搞定