2016-09-15 33 views
-1

私はImagick DLL successfully.Iがインストールされているが、次のPHPでImagickライブラリを使用してpdfファイルをイメージに変換するには?

How do I convert a PDF document to a preview image in PHP?

次のstackoverflow exmpleに従っている私のコード

<?php 
$im = new imagick('file.pdf[0]'); 
$im->setImageFormat('jpg'); 
header('Content-Type: image/jpeg'); 
echo $im; 
?> 

ですが、私は今、次のエラー

Fatal error: Uncaught exception 'ImagickException' with message 'UnableToOpenBlob `demo.pdf': No such file or directory @ error/blob.c/OpenBlob/2657' in D:\xampp\htdocs\learn\index.php:2 Stack trace: #0 D:\xampp\htdocs\learn\index.php(2): Imagick->__construct('demo.pdf[0]') #1 {main} thrown in D:\xampp\htdocs\learn\index.php on line 2 

Imagick取得していますdllインストールpropelry

添付screnshot enter image description here 親切にいくつかのいずれかが、おかげで

答えて

0
public function pdfToJpg($param){ 
     $filename = $param['filename']; 
     $image_name = $param['image_name']; 
     $path = $param['path']; 
     $db_path = $param['db_path']; 
     $im = new Imagick(); 
     $im->setResolution(220,220); 
     $im->readimage($filename."[0]"); 
     $im->setImageFormat('jpeg'); 
     $im->setImageBackgroundColor('#ffffff'); 
     $im->flattenImages(); 
     $image_name = $image_name.".jpg";//"save_as_name.jpg"; 
     $imageprops = $im->getImageGeometry(); 
     /*if ($imageprops['width'] <= 175 && $imageprops['height'] <= 300) { 
     // don't upscale 
     } else { 
     $im->resizeImage(175,300, imagick::FILTER_LANCZOS, 0.9, true); 
     }*/ 

     $im->writeImage($path.$image_name); 
     if($im){ 
      $Img = array(); 
      $Img['status'] = 1; 
      $Img['image'] = ($db_path.$image_name); 
      return $Img; 
     } 
     $im->clear(); 
     $im->destroy(); 
    } 

それを試してみてください?この問題を解決する方法を私を助けます
関連する問題