TP5图片处理常见问题


一、Class 'think\Image' not found

composer require topthink/think-image 装上了扩展
控制器头部加了 use think\Image
然后\think\image::open($imgSrc);提示Class 'think\Image' not found

最简单的解决方法是把 ./vendor/topthink/think-image/src下的文件(包括image.php和image文件夹)
移动到 ./thinkphp/library/think 目录下,
再回到原来的程序中,就不会报错了
 
 
 

二、Image::open 处理图片失败

处理6MB以上的图片时会发生内存溢出? "Allowed memory size of 268435456 bytes exhausted (tried to allocate 84105217 bytes)...topthink/think-image/src/Image.php:267"

 

因为处理高清图造成的内存崩溃所以无法返回处理结果。

处理方法:修改 memory_limit 为256M后,复试,成功。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM