PHP GD库处理JPG图片大小变模糊的解决办法
问题描述:
在用PHPCMS的thumb函数时,JPG图片变化大小后,质量会下降很多。
经研究,是PHP的imagejpeg函数的问题,最后修改此函数为imagepng后,问题得以解决。
下面把实现代码,分享给大家。
代码:
<?php
header("Content-type: image/png");
$temp_width = 150;
$temp_height = 180;
$img_path = "test.jpg";
$img_path2 = "test2.jpg";
$im = @imagecreatefromjpeg($img_path);
$temp_img=imagecreatetruecolor($temp_width,$temp_height);
imagecopyresampled($temp_img,$im,0,0,0,0,$temp_width,$temp_height,$temp_width,$temp_height);
//echo $temp_img;
//imagejpeg($temp_img);
imagepng($im,$img_path2);
/*
imagecopyresized($temp_img,$im,0,0,0,0,$temp_width,$temp_height,$srcW,$srcH);
$ni=imagecreatetruecolor($width,$height);
imagecopyresampled
$res = function_exists('imagecreatetruecolor');
var_dump($res);
*/
?>
<br />
<img src="http://www.jbxue.com/ /test.jpg"/>
您可能感兴趣的文章:
PHP GD库处理JPG图片大小变模糊的解决办法
php GD库函数getimagesize()的用法
php绘图不显示图片怎么办
windows下开启PHP GD库的方法
php gd库的基础知识
PHP图片裁剪函数(图像不变形)
php开启GD库(windows环境)
Linux下开启PHP GD库支持
AI源文件转photoshop图像变模糊问题解决教程
uc浏览器浏览时图片模糊怎么回事