代码之家  ›  专栏  ›  技术社区  ›  Karl Johan Vallner

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

  •  0
  • Karl Johan Vallner  · 技术社区  · 7 年前

    我正在用PHP7.2将PDF-s转换为PNG-s,使用Ghostscript 9.18,它可以按预期工作,但更大的PNG-s(100MB+)很容易需要10分钟才能转换,我想把这10分钟缩短到几秒钟。

    我以为我能在这里做什么?

    我是这样管理Imagick的

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

    但这将导致5-10分钟的加载时间。在查看htop时,大多数情况下,“gs”命令正在运行,解析PDF。我从这个线程中查找了几个ghostscript选项 Any tips for speeding up GhostScript? 我想用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)
    

    但我不知道如何将Ghostscript选项传递给Imagick,在运行Ghostscript时,Imagick会将这些选项委托给Ghostscript。

    有人对如何解决这个问题有什么想法吗?

    0 回复  |  直到 7 年前