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