douliaodun9153 2018-10-25 23:50
浏览 174

php Imagick PDF到PNG转换传递Ghostscript [gs]选项

I am converting PDF-s to PNG-s in PHP 7.2, whith Ghostscript 9.18 and it works as expected, but bigger PNG-s (100MB+) easily take over 10 minutes to convert and I would like to bring this 10 minutes down to a few seconds.

What I thought I could do here?

I am running Imagick like this

$this->imagick = new Imagick($pdfFile);

But it will result in a 5-10 minute load time. When looking at htop, most of the time, the "gs" command is running, parsing the PDF. I looked up a few ghostscript options from this thread Any tips for speeding up GhostScript? and I would like to test them with Imagick.

                            %-> comments to the right 
-dNumRenderingThreads=8     % increasing up to 64 didn't make much difference
-dBandHeight=100            % didn't matter much
-dBandBufferSpace=500000000 % (500MB)
-sBandListStorage=memory    % may or may not need to be set when gs is compiled
-dBufferSpace=1000000000    % (1GB)

But I can't figure out, how to pass Ghostscript options to Imagick, which would them delegate these to Ghostscript, when running it.

Does anybody have any ideas on how to solve this issue?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集