Posted By

alessio2 on 02/07/11


Tagged

image jpg pdf imagemagick convert imagick pdf2jpg


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

alessio2
albertomori
mgerdt
benediktvaldez
wirenaught
virpara
eludnasud
Decepticon
shuraki
Priestd09
philik
tux-world


PDF2JPG - convert PDF to JPG images with ImageMagick


 / Published in: PHP
 

ImageMagick must be installed on server for this operation
  1. /**
  2.  * PDF2JPG script
  3.  * with ImageMagick
  4.  */
  5.  
  6. $pdf_file = './pdf/demo.pdf';
  7. $save_to = './jpg/demo.jpg'; //make sure that apache has permissions to write in this folder! (common problem)
  8.  
  9. //execute ImageMagick command 'convert' and convert PDF to JPG with applied settings
  10. exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var);
  11.  
  12.  
  13. if($return_var == 0) { //if exec successfuly converted pdf to jpg
  14. print "Conversion OK";
  15. }
  16. else print "Conversion failed.<br />".$output;

Report this snippet  

You need to login to post a comment.