我已经从网上安装了imageMagick和ghostscript,并将其放入mamp中,但我不知道如何将它们包含在我的php代码中。。通过谷歌搜索,我发现了一个代码
<?php
$pdf = 'serviceReport.pdf';
$save = 'output.jpg';
exec('convert "'.$pdf.'" -colorspace RGB -resize 800 "'.$save.'"', $output, $return_var);
?>
但是我没有得到结果。。有人能帮上这个吗
使用ImageMagick提供的php扩展(Imagick)而不是命令行工具是非常有效的:
<?php
// ...
$img = new 'Imagick();
$img->readimage($filedata['tmp_name']); // this can be a pdf file!
$img->setResolution(300,300);
$img->writeImage(sprintf('%1$s/%2$s.jpg', $basepath, $basename));
// ...
?>
另一种选择是使用poppler工具。它们提供了更快的处理速度。