//图片压缩开始了
if($fileInfo['type']=='image/jpeg' || $fileInfo['type']=='image/png' || $fileInfo['type']=='image/gif' || $fileInfo['type']=='image/jpg' || $fileInfo['type']=='image/webp')
{
if($fileInfo['type']=='image/png' || $fileInfo['type']=='image/gif'){
$this->ImageToJPG($img_path, $img_path, $imagewidth , $imageheight);
}
require_once VENDOR_PATH.'topthink/think_image.php';
$image = \think\Image::open($img_path);
if($imagewidth < 720){
if($imagewidth > $imageheight){
$image->thumb($imagewidth, $imageheight)->save($img_path);
//file_put_contents(ROOT_PATH.'/1.txt', print_r($imagewidth, true));
}else{
$image->thumb($imagewidth, $imagewidth, 3)->save($img_path);
$imageheight = $imagewidth;
}
}else{
//file_put_contents(ROOT_PATH.'/kiqik.txt', print_r('kiqik', true));
if($imagewidth > $imageheight){
$zoom = $imagewidth / 720;
$image->thumb(720, $imageheight/$zoom)->save($img_path);
$imageheight = $imageheight/$zoom;
$imagewidth = 720;
}else{
$image->thumb(720, 720, 3)->save($img_path);
$imagewidth = 720;
$imageheight = 720;
}
}
clearstatcache();
$fileInfo['size'] = filesize($img_path);
}
//图片压缩结束了
版权属于:
admin
作品采用:
《
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
》许可协议授权
评论 (0)