gpt4 book ai didi

php - 使用 PHP gd 库提高图像质量

转载 作者:可可西里 更新时间:2023-11-01 13:42:05 24 4
gpt4 key购买 nike

不知道在哪里,但我遇到了一个图像托管网站,它允许您以大格式上传图像或对其进行锐化。

我个人不记得或不知道 GD 库有任何锐化图像的功能,这可能只是质量提升的不同词。

如果有人知道锐化图像的功能,请告诉我,因为我个人在 Image Magic 和/或 GD 库中都不知道此类功能。

  • 提前致谢

最佳答案

您可以使用 imageconvolution在带有锐化蒙版的 GD 中。来自 http://adamhopkinson.co.uk/blog/2010/08/26/sharpen-an-image-using-php-and-gd/ :

PHP and GD can sharpen images by providing a matrix to imageconvolution:

// create the image resource from a file
$i = imagecreatefromjpeg('otter.jpg');

// define the sharpen matrix
$sharpen = array(
array(0.0, -1.0, 0.0),
array(-1.0, 5.0, -1.0),
array(0.0, -1.0, 0.0)
);

// calculate the sharpen divisor
$divisor = array_sum(array_map('array_sum', $sharpen));

// apply the matrix
imageconvolution($i, $sharpen, $divisor, 0);

// output the image
header('Content-Type: image/jpeg');
imagejpeg($i);

关于php - 使用 PHP gd 库提高图像质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6141713/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com