doulan9188 2010-04-07 14:28
浏览 48

将动态PDF管道输入Imagemagick并转换为PNG

I need to create thumbnails from dynamic (database driven) pdf's. I've used a variation of the script below in the past, but this doesn't seem to be working for me now (page just hangs).

<?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;

   ?>

Could anyone help me out with this please? Much appreciated :)

  • 写回答

1条回答 默认 最新

  • doutuo6689 2010-04-07 14:38
    关注

    Magick can open PDFs natively:

    $im = new MagickWand('file.pdf[3]');  // open page 3 of the PDF
    $png = $im->whateverTheMethodIsForPNG();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?