How can imagecopyresized in PHP affect the colors of resized images?

When using imagecopyresized in PHP to resize images, the colors of the resized image may appear distorted or altered due to the interpolation method used during the resizing process. To maintain the original colors of the image, you can specify the interpolation method as IMG_BILINEAR_FIXED in the imagecopyresampled function. This will help preserve the colors and reduce distortion in the resized image.

$source = imagecreatefromjpeg('original.jpg');
$destination = imagecreatetruecolor(200, 200);
imagecopyresampled($destination, $source, 0, 0, 0, 0, 200, 200, imagesx($source), imagesy($source), IMG_BILINEAR_FIXED);
imagejpeg($destination, 'resized.jpg');
imagedestroy($source);
imagedestroy($destination);