Home > php教程 > php手册 > body text

3.2版本图片压缩的处理

WBOY
Release: 2016-06-07 11:37:11
Original
1274 people have browsed it

1. 关于上传的图片压缩的处理
2. 缩写后的图片显示不清晰的处理
为了节约云服务器空间,需要对上传的图片进行压缩处理,但在使用的过程中发现Image.class.php和Gd.class.php类有几处错误的定义。

1. Image.class.php中的方法thumb,最后一个参数写错了,应该是:IMAGE_THUMB_SCALING

2.Image.class.php中的方法__construct,$class写错了,应该是:Imagick 和 Gd

3. 上面两个改完后,可以压缩了,发现图片不清晰,这个需要改:Gd.class.php中的save方法,把 imagejpeg($this->img, $imgname,80);
把 80 修改成 100 既可以了

调用就非常简单了
$image = new \Think\Image();
$image->open('./Uploads/Picture/'.$img_url);
$image->thumb(640, 640)->save('./Uploads/Picture/'.$img_url);

附件 thumb.zip ( 6.04 KB 下载:38 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!