Home > Backend Development > PHP Tutorial > php convert PDF to JPG

php convert PDF to JPG

*文
Release: 2023-03-18 14:20:01
Original
2847 people have browsed it

How to convert PDF to JPG in php? This article mainly introduces the method of using PHP to convert PDF files to JPG files using Image Magick, and involves the techniques of PHP using Image Magick extension to manipulate images. I hope to be helpful.

The details are as follows:

This is a very simple format conversion code that can convert .PDF files into .JPG files. For the code to work, the server must have the Image Magick extension installed.


$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.".$output;
Copy after login

Related recommendations:

##php thumbnail generation class, supports imagemagick and gd libraries Processing

How to use php_imagick to achieve retro effect_php example

##PHP’s ImageMagick use;

The above is the detailed content of php convert PDF to JPG. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template