What are the differences between imagecopy and imagecopyresampled functions in PHP when it comes to handling transparency and resizing images?

When resizing images with transparency in PHP, the imagecopy function does not handle transparency well and can result in jagged edges or loss of transparency. On the other hand, the imagecopyresampled function handles transparency better when resizing images, resulting in smoother edges and maintaining transparency.

// Original image
$source = imagecreatefrompng('original.png');

// Create a new image with the desired dimensions
$destination = imagecreatetruecolor(200, 200);

// Copy and resize the original image to the new image using imagecopyresampled
imagecopyresampled($destination, $source, 0, 0, 0, 0, 200, 200, imagesx($source), imagesy($source));

// Output the resized image
header('Content-Type: image/png');
imagepng($destination);

// Free up memory
imagedestroy($source);
imagedestroy($destination);