当前位置:Gxlcms > PHP教程 > phppdf文件转图片

phppdf文件转图片

时间:2021-07-01 10:21:17 帮助过:4人阅读

为什么会文件读取不到,路径 pdf文件权限都已设置

$PDF = './22.pdf';

$IM =new imagick();
   $IM->setResolution(120,120);
   $IM->setCompressionQuality(100);
   $IM->readImage($PDF);
   foreach($IM as $Key => $Var){
       $Var->setImageFormat('png');
       $Filename = './'.md5($Key.time()).'.png';
       if($Var->writeImage($Filename)==true){
           $Return[]= $Filename;
       }
   }

报错内容:Fatal error: Uncaught exception 'ImagickException' with message 'Failed to read the file' in

回复内容:

为什么会文件读取不到,路径 pdf文件权限都已设置

$PDF = './22.pdf';

$IM =new imagick();
   $IM->setResolution(120,120);
   $IM->setCompressionQuality(100);
   $IM->readImage($PDF);
   foreach($IM as $Key => $Var){
       $Var->setImageFormat('png');
       $Filename = './'.md5($Key.time()).'.png';
       if($Var->writeImage($Filename)==true){
           $Return[]= $Filename;
       }
   }

报错内容:Fatal error: Uncaught exception 'ImagickException' with message 'Failed to read the file' in

$PDF使用绝对路径呢

try {
    // read img
}  catch (ImagickException $e) {
    echo  exception;
}

人气教程排行