I am using Imagick to convert the first page of a PDF to a PNG image. It is working, but it is very slow.
A conversion takes between 8 and 20 seconds for a ~100kb PDF.
Is there a way to speed up the conversion?
My code :
$im = new Imagick($url);
$im->setIteratorIndex(0);
$im->setCompression(Imagick::COMPRESSION_LZW);
$im->setCompressionQuality(90);
$im->setImageFormat("png");
$im->writeImage('C:/Shared/test.png');
In fact , I don’t need Imagick library to generate a simple JPG preview of the first page of a PDF, I just need GhostScript.
Command line conversion with GhostScript is always faster than Imagick (command line or through PHP)
Example with a 12 pages and 650kb :
With some documents, Imagick takes 20 seconds against 1.5 second with direct GS command line.
Here is my test script