What potential data loss issues can occur when using imagecopyresized() in PHP?

When using imagecopyresized() in PHP to resize images, potential data loss issues can occur due to the loss of image quality or distortion of the image. To solve this problem, it is recommended to use imagecopyresampled() instead, as it provides better quality results when resizing images.

// Original image
$source = imagecreatefromjpeg('original.jpg');

// New image dimensions
$width = 200;
$height = 150;

// Create a new image with resampled quality
$destination = imagecreatetruecolor($width, $height);
imagecopyresampled($destination, $source, 0, 0, 0, 0, $width, $height, imagesx($source), imagesy($source));

// Save the resized image
imagejpeg($destination, 'resized.jpg');

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