Home > Article > Backend Development > How to use Image Magick to convert PDF files to JPG files in php_PHP Tutorial
This is a very simple format conversion code that can convert .PDF files into .JPG files, code To work, the server must have the Image Magick extension installed.
4 11 12 |
$pdf_file = './pdf/demo.pdf'; $save_to = './jpg/demo.jpg'; //make sure that apache has permissions to write in this folder! //(common problem) //execute ImageMagick command 'convert' and convert PDF //to JPG with applied settings exec('convert "'.$pdf_file.'" -colorspace RGB -resize 800 "'.$save_to.'"', $output, $return_var); if($return_var == 0) { //if exec successfully converted pdf to jpg print "Conversion OK"; } else print "Conversion failed.".$output; |