I have a piece of code that takes an image as input and does a resize (scaling up, making it bigger). Input image does not contain any anti-alias, it means that it has sharp borders and corners. I want this scaling procedure to add anti-alias to have smooth borders and edges, like some graphic programs do (for example paint.NET, if I make the image bigger, anti-alias is automatically added). How can I do that?
Here is my code
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;
}
Thank you for any help.
EDIT: i tried to add interpolation
imagesetinterpolation($output,IMG_BICUBIC);
but nothing changed.