How can ImageMagick be utilized for image processing in PHP, specifically for generating thumbnails?
ImageMagick can be utilized in PHP for image processing tasks such as generating thumbnails. By using the ImageMagick library, you can easily resize images to create thumbnails of various sizes. This can be achieved by installing the ImageMagick PHP extension and then using the appropriate functions to manipulate the images.
// Path to the original image
$originalImage = 'path/to/original/image.jpg';
// Path where the thumbnail will be saved
$thumbnailPath = 'path/to/save/thumbnail.jpg';
// Create a new Imagick object
$image = new Imagick($originalImage);
// Resize the image to create a thumbnail
$image->thumbnailImage(100, 100);
// Save the thumbnail image
$image->writeImage($thumbnailPath);
// Clear resources
$image->clear();
$image->destroy();