1
我需要从动态(数据库驱动)pdf创建缩略图。过去我已经使用过以下脚本的变体,但现在看起来并不适合我(页面刚刚挂起)。将动态PDF转换为Imagemagick并转换为PNG
<?php
require_once('./template/all_includes.php');
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);
$cwd = '/tmp';
$env = array('asdfadf' => '193');
$convert = "convert pdf:- png:-";
$process = proc_open($convert, $descriptorspec, $pipes, $cwd, $env);
fwrite($pipes[0], 'php /var/www/html/domain.co.uk/store/pdf.php');
fclose($pipes[0]);
while(!feof($pipes[1])) $im .= fread($pipes[1], 1024);
fclose($pipes[1]);
$return_value = proc_close($process);
header("Content-Type: image/png");
echo $im;
?>
有人能帮我解决这个问题吗?非常感谢:)
我想避免API的是对性能的影响是在执行exec显著() – 2010-04-07 14:43:52
在哪里我使用'EXEC()'? – 2010-04-07 15:30:52
我不是很清楚。使用PHP Native API的性能比使用命令行(通过exec或类似)有显着的性能。因此我需要使用我概述的方法。 – 2010-04-08 08:25:36