Are there any specific PHP functions or libraries recommended for resizing images in PHP?

When resizing images in PHP, the `imagecopyresampled()` function is commonly used to create a resized image with better quality compared to `imagecopyresized()`. Additionally, the GD library in PHP provides various functions for image manipulation, such as `imagecreatefromjpeg()` and `imagejpeg()`, which can be used in conjunction with `imagecopyresampled()` for resizing images.

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

// Get the dimensions of the original image
$originalWidth = imagesx($originalImage);
$originalHeight = imagesy($originalImage);

// Set the desired width and height for the resized image
$desiredWidth = 300;
$desiredHeight = 200;

// Create a new image with the desired dimensions
$resizedImage = imagecreatetruecolor($desiredWidth, $desiredHeight);

// Resize the original image to fit the new dimensions
imagecopyresampled($resizedImage, $originalImage, 0, 0, 0, 0, $desiredWidth, $desiredHeight, $originalWidth, $originalHeight);

// Save the resized image to a new file
imagejpeg($resizedImage, 'resized.jpg');

// Free up memory
imagedestroy($originalImage);
imagedestroy($resizedImage);