php调整图像没有损失质量

我已经实现了这个方法(通过以下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

imagecopyresampled() copies a rectangular portion of one image to another image,smoothly interpolating pixel values so that,in particular,reducing the size of an image still retains a great deal of clarity.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...