When trying to open a very high DPI (1200 in this case) PDF PHP uses a full CPU core until timeout regardless of file size or complexity of the PDF. This happens on construct of the imagick object before I can check the PDF dimensions.
To replicate make a 10200x13200 gray square in sketch (or your app of choice) and export to PDF. The file will be small (<10kb) but IMagick can't load it in a reasonable amount of time.
Here's the code I used to test:
Code: Select all
$im = new \imagick('/path/to/file.pdf');
$properties = $im->identifyImage();
I timeout while processing the first line. I'm looking for a work around that would let me get the resolution of the PDF before I try to open it so I can prevent a PHP timeout. The PDFs I'm processing are uploaded by end-users. I restrict file size (3MB in this case), page size (8.5" x 11"), and page count (1). I get the file size from the POST, but page size and count I'm getting with IMagick.
The problem being that a high resolution low file size PDF will simply timeout. Does anyone know of a solution for this?