Created
December 3, 2013 16:38
-
-
Save enopanen/7772506 to your computer and use it in GitHub Desktop.
Convert .pdf files to .jpg using PHP and Image Magick
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 successfuly converted pdf to jpg | |
print "Conversion OK"; | |
} | |
else print "Conversion failed.<br />".$output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great work! This is a great solution to convert pdf file to jpg image I've appreciated.