Php 缩放图像(放大)使用GD库添加反别名

Php 缩放图像(放大)使用GD库添加反别名,php,image,gd,Php,Image,Gd,我有一段代码,它将图像作为输入并调整大小(放大,使其更大)。输入图像不包含任何反别名,这意味着它具有锐利的边框和角。 我希望此缩放过程可以添加抗锯齿,使其具有平滑的边框和边缘,就像某些图形程序所做的那样(例如,paint.NET,如果我将图像放大,则会自动添加抗锯齿)。 我该怎么做 这是我的密码 private function resize($source_path, $dest_path, $dest_w, $dest_h) { $source = imagecreatefrompn

我有一段代码,它将图像作为输入并调整大小(放大,使其更大)。输入图像不包含任何反别名,这意味着它具有锐利的边框和角。 我希望此缩放过程可以添加抗锯齿,使其具有平滑的边框和边缘,就像某些图形程序所做的那样(例如,paint.NET,如果我将图像放大,则会自动添加抗锯齿)。 我该怎么做

这是我的密码

private function resize($source_path, $dest_path, $dest_w, $dest_h)
{
    $source = imagecreatefrompng($source_path);
    $source_w = imagesx($source);
    $source_h = imagesy($source);

    $output = imagecreatetruecolor($dest_w, $dest_h);
    imagealphablending($output, false);
    $transparent = imagecolorallocatealpha($output, 0, 0, 0, 127);
    imagefilledrectangle($output, 0, 0, $dest_w, $dest_h, $transparent);
    imagesavealpha($output, true);

    if (imagecopyresampled($output, $source, 0, 0, 0, 0, $dest_w, $dest_h, $source_w, $source_h)) {
        if (imagepng($output, $dest_path)) {
            return true;
        }
    }

    return false;
}
谢谢你的帮助

编辑:我尝试添加插值

imagesetinterpolation($output,IMG_BICUBIC);

但一切都没有改变。

你能展示一下当前发生的事情吗?根据我的经验,通过
imagecopyresampled
对真彩色输出进行任何调整都会自动产生抗锯齿效果。我无法上传图像。。。由于验证问题,编辑器中存在一些错误。无论如何,结果是完全相同的图像,缩放,没有反别名在allI意味着上传图像到您的SO问题发生了什么,否则我们只是猜测。