How can the quality of thumbnails generated in PHP be improved, especially when using the GD library?

When generating thumbnails in PHP using the GD library, the quality can be improved by using the `imagecopyresampled()` function instead of `imagecopyresized()`. This function will produce higher quality thumbnails by using interpolation to create a smoother image.

// Load the original image
$original_image = imagecreatefromjpeg('original.jpg');

// Create a new image resource for the thumbnail
$thumbnail = imagecreatetruecolor($new_width, $new_height);

// Copy and resize the original image to the thumbnail using imagecopyresampled
imagecopyresampled($thumbnail, $original_image, 0, 0, 0, 0, $new_width, $new_height, $original_width, $original_height);

// Output the thumbnail
imagejpeg($thumbnail, 'thumbnail.jpg');

// Free up memory
imagedestroy($original_image);
imagedestroy($thumbnail);