php调整图像没有损失质量
发布时间:2020-12-13 14:07:57 所属栏目:PHP教程 来源:网络整理
导读:我已经实现了这个方法(通过以下php教程)来创建图像的预览: function createPreview($image_path,$filename) { header('Content-Type: image/jpeg'); $thumb = imagecreatetruecolor(350,350); $source = imagecreatefromjpeg($image_path); list($width,$he
我已经实现了这个方法(通过以下php教程)来创建图像的预览:
function createPreview($image_path,$filename) { header('Content-Type: image/jpeg'); $thumb = imagecreatetruecolor(350,350); $source = imagecreatefromjpeg($image_path); list($width,$height) = getimagesize($image_path); imagecopyresized($thumb,$source,350,$width,$height); imagejpeg($thumb,$filename."_prev.jpg"); } 但我注意到缩放图像损失了很多质量.我怎样才能保持缩放图像的质量(我不能使用想象力,我的服务器不支持它)
imagejpeg默认使用75质量.所以你需要明确定义它.
imagejpeg($thumb,$filename."_prev.jpg",100); 另外,使用imagecopyresampled
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |