有些图片可能人为的修改了后缀,导致imagecreatefrompng报错,PS也打不开这种图
报错
imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data
PS甚至也打不开
各位有什么好的解决方案吗?
关于 LearnKu
尝试过这个方法么?
imagecreatefromstring(file_get_contents($this->FilePath));试下这个
\Illuminate\Filesystem\FilesystemguessExtension()mime_content_type('filename.jpg');
试试这个
我建议你直接解决这样的用户就行了
gd 可以用 getimagesize 获取图片信息,再配合 image_type_to_extension 获取后缀