This article mainly introduces PHP using Imagick to read the first page of the PDF to generate PNG thumbnail two methods, using the PHP extension Php_imagick, the need for friends can refer to the following
What is ImageMagick? ImageMagick is a powerful, stable and free toolset and development kit that can be used to read, write, and process picture files in more than 185 basic formats, including popular TIFF, JPEG, GIF, PNG, PDF and PHOTOCD formats. With ImageMagick, you can dynamically generate pictures based on the needs of your Web application, and you can resize, rotate, sharpen, subtractive, or add special effects to one (or a group) of pictures and save the results of the operation in the same format or in other formats. Second, Php_imagick What a php extension can be used to invoke the ImageMagick function of PHP. Using this extension enables PHP to have the same functionality as ImageMagick. Three ways to generate PNG thumbnails in PDF the first: code is as follows:/** * pdf2png * @param $pdf pending PDF file * @param $path the path of the picture to be saved * @par Am $page the page to be exported-1 is all 0 is first page 1 is the second page * @return saved picture path and filename * * * function pdf2png ($pdf, $path, $page =0) { if (!is_dir ($path)) { mkdir ($path, true); } &nbs P if (!extension_loaded (' Imagick ')) { echo ' not found imagick! ' ; return false; &NBSP if (!file_exists ($pdf)) { echo ' no pdf found '; &nbs P return false; &NBSP;} $im = new Imagick (); $im->setresolution (120,120); //Set image resolution $im->setcompressionquality (80); Compression ratio $im->readimage ($pdf. " [". $page."]); Sets the first page of the Read PDF //$im->thumbnailimage (true); Change the size of the image $im->scaleimage (200,100,true); Shrink Zoom image $filename = $path. " /". Time (). '. PNG '; if ($im->writeimage ($filename) = = true) { $Return = $filenam E   return $Return; } $s = pdf2png (' file/1371273225-ceshi_ppt.pdf ', ' images '); echo ' <div align= ' center ' ><img Src= "'. $s. ' ></div> '; Second: The code is as follows: function Pdf2png ($PDF, $Path) { if (!extension_loaded (' Imagick ')) { return False &NBSP} if (!file_exists ($PDF)) { return false; } $IM = NE W Imagick (); $IM->setresOlution (120,120); $IM->setcompressionquality (100); $IM->readimage ($PDF); foreach ($IM as $Key => $Var) { $Var->setimageformat (' png '); $Fi Lename = $Path. ' /'. MD5 ($Key. Time ()). PNG '; if ($Var->writeimage ($Filename) = = True) { $Return [] = $Filename; & nbsp &NBSP} } return $Return; }