PHP imagecreatefromjpeg 和 imagecopy 在图像上创建像素化和非常差的质量

标签 php image-processing gd

使用此代码后(仅处理图像的部分)

$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]);

我得到的像素化结果非常非常差,你可以在这里看到 enter image description here

这是原图

enter image description here

PHP 版本 5.3.18

捆绑了 GD 版本(兼容 2.0.34)

使用 GD 对我来说是必须的。这个例子在许多服务器上运行良好,但在一些服务器上我得到了这个糟糕的结果,我想知道原因。

有什么帮助吗?

最佳答案

我在指定质量百分比时解决了同样的问题。

imagejpeg($im, 'watemark.jpg', 100);

或 75 等。

http://php.net/manual/en/function.imagejpeg.php

关于PHP imagecreatefromjpeg 和 imagecopy 在图像上创建像素化和非常差的质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18249482/

相关文章:

php - 如果使用中文字符,为什么 php md5() 总是与 python 的 hash.md5() 不同?

php - 使用 PHP 在文本框中显示动态文本时转义单引号和双引号

Java与指纹识别

php - 使用 GD 和 PHP 居中对齐多行文本

PHP:如何将非真彩色图像转换为真彩色图像?

php - 如何在 PHP 中处理大于 16 位的值?

javascript - 如何将javascript放入php函数中

visual-c++ - Opencv中cv MatchTemplate()函数的用法

python - 在 Python 中使用 float 切片 ndarray

PHP - 在图像上 mask 多边形