当前位置 : 主页 > 网络编程 > PHP >

PHP利用imagick把PDF转成PNG

来源:互联网 收集:自由互联 发布时间:2021-07-03
function pdf2png($PDF,$Path){ if(!extension_loaded('imagick')){ return false; } if(!file_exists($PDF)){ return false; } $IM = new imagick(); $IM-setResolution(120,120); $IM-setCompressionQuality(100); $IM-readImage($PDF); foreach ($IM as $K
 
function pdf2png($PDF,$Path){
   if(!extension_loaded('imagick')){
       return false;
   }
   if(!file_exists($PDF)){
       return false;
   }
   $IM = new imagick();
   $IM->setResolution(120,120);
   $IM->setCompressionQuality(100);
   $IM->readImage($PDF);
   foreach ($IM as $Key => $Var){
       $Var->setImageFormat('png');
       $Filename = $Path.'/'.md5($Key.time()).'.png';
       if($Var->writeImage($Filename) == true){
           $Return[] = $Filename;
       }
   }
   return $Return;
网友评论