Tp6图像处理生成缩略图方法 发布时间:2023/10/11 tp5.1的扩展库中有图像处理功能,tp6没有,默认没有安装,图像库是一个工具库 任何版本TP都可以用1、使用Composer安装ThinkPHP6的图像处理类库:composer require topthink/think-image复制代码2、执行更新命令composer update复制代码3、使用方法:<?php $og_thumb = public_path().$goods->og_thumb; $image = \think\Image::open($og_thumb); //生成缩略图 //小缩略图 $sm_thumb = 'sm_'.$file_name; //中缩略图 $mid_thumb = 'mid_'.$file_name; //大缩略图 $big_thumb = 'big_'.$file_name; $image->thumb(500, 500)->save(public_path().$file_path.$big_thumb); $image->thumb(200, 200)->save(public_path().$file_path.$mid_thumb); $image->thumb(80, 80)->save(public_path().$file_path.$sm_thumb); ?>复制代码注意:这里如果生成多张缩略图的话图片大小尺寸顺序要从大到小顺序。最终效果图:生原图,500*500、200*200、80*80的尺寸图片