图片压缩的有关问题

WBOY
Release: 2016-06-13 12:15:24
Original
1012 people have browsed it

图片压缩的问题
imagecreatefromjpeg操作jpg图片压缩时候警告,图片为0字节。本地是可以的。服务器上不行。看了PHP的GD也有打开,不知道是什么原因了?


------解决思路----------------------
你的服务器在编译 gd 是没有打开 --jpeg 开关

------解决思路----------------------
gd有問題,重裝一個看看。
------解决思路----------------------
先判断一下图片类型,再用调用对应的方法打开。

<br />$obj = new finfo(FILEINFO_MIME_TYPE);<br />$type = $obj->file($file);<br /><br />switch($type){<br />    case 'image/gif': $img = imagecreatefromgif($file); break;<br />    case 'image/jpeg': $img = imagecreatefromjpeg($file); break;<br />    case 'image/png': $img = imagecreatefrompng($file); break;<br />    default: return false;<br />}<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template