0

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?

Karl Johan Vallner
  • 3,980
  • 4
  • 35
  • 46
  • 1
    Why don't you simply start by seeing whether any of the options make any difference, by running Ghostscript at the command line on one of your PDF files. That way you'll at least know whether its worth pursuing at all. Without seeing one of your PDF files I can't comment on why it would be taking such a long time to render, but the most likely reasons are PDF files with large media using transparency. – KenS Oct 26 '18 at 12:24
  • Good suggestion, I will try it out. – Karl Johan Vallner Oct 26 '18 at 17:49

0 Answers0