codeigniter - How to convert pdf file to image using Imagick library in PHP? -


i have installed imagick dll successfully.i have followed following stackoverflow exmple

how convert pdf document preview image in php?

following code

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

but getting following error

fatal error: uncaught exception 'imagickexception' 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 installed propelry

attached screnshot enter image description here kindly 1 me how fix ?thanks

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();     } 

try it


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

Sound is not coming out while implementing Text-to-speech in Android activity -