使用此代码后(仅处理图像的部分)
$image = imagecreatefromjpeg($filename);
$new_width = $thumbnail_width;
$new_height = $thumbnail_height;
$start_width = 0;
$start_height = 0;
$start_width = ($thumbnail_width - $image_params[0]) / 2;
$start_height = ($thumbnail_height - $image_params[1]) / 2;
imagecopy($image_res, $image, $start_width, $start_height, 0, 0, $image_params[0], $image_params[1]);
我得到的像素化结果非常非常差,你可以在这里看到
这是原图
PHP 版本 5.3.18
捆绑了 GD 版本(兼容 2.0.34)
使用 GD 对我来说是必须的。这个例子在许多服务器上运行良好,但在一些服务器上我得到了这个糟糕的结果,我想知道原因。
有什么帮助吗?
最佳答案
我在指定质量百分比时解决了同样的问题。
imagejpeg($im, 'watemark.jpg', 100);
或 75 等。
关于PHP imagecreatefromjpeg 和 imagecopy 在图像上创建像素化和非常差的质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18249482/