×

Welcome to TagMyCode

Please login or create account to add a snippet.
1
0
 
0
Language: PHP
Posted by: A973C FR
Added: Sep 24, 2012 5:30 AM
Views: 56
  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;