What is the recommended method for generating a thumbnail from the first page of a PDF document using PHP?

When generating a thumbnail from the first page of a PDF document using PHP, you can use the Imagick extension to extract the first page as an image and then resize it to create a thumbnail.

// Load the PDF file
$pdf = new Imagick('document.pdf[0]');

// Convert the first page to an image
$pdf->setImageFormat('jpeg');

// Resize the image to create a thumbnail
$pdf->resizeImage(100, 100, Imagick::FILTER_LANCZOS, 1);

// Save the thumbnail image
$pdf->writeImage('thumbnail.jpg');

// Clear resources
$pdf->clear();
$pdf->destroy();