steph072
I did some further tests, and indeed it's your PHP Imagick extension failing with PDF, while your ImageMagick CLI succeeds. In the change I suggested in my previous post, we hadn't completely disabled PHP Imagick.
Working latest version with modified code (you know the full link):
/test/newversion/new.php
Code that must be modified in latest version:
// line 764 comment out:
// if(extension_loaded('imagick')) return self::$imagemagick = 'imagick';
// line 1688 return false and comment out existing code:
return false;//$this->app === 'imagemagick' && extension_loaded('imagick');
So why isn't it working?
I did some further tests on your server with file test/newversion/test.php, and this is the error it outputs:
Fatal error: Uncaught ImagickException: NotAuthorized `PDF' @ error/constitute.c/IsCoderAuthorized/422 in /volume1/web/lukasz/test/newversion/test.php:10 Stack trace: #0 /volume1/web/lukasz/test/newversion/test.php(10): Imagick->__construct('./report.pdf') #1 {main} thrown in /volume1/web/lukasz/test/newversion/test.php on line 10
Looks like you have some security policy issue. According to Google AI:
The ImagickException: NotAuthorized 'PDF' @ error/constitute.c/IsCoderAuthorized/422 error indicates that ImageMagick, and by extension the PHP Imagick extension, is preventing the processing of PDF files due to a security policy. This policy was introduced in a 2018 ImageMagick security update to mitigate potential vulnerabilities related to Ghostscript-handled file types.
To resolve this, the ImageMagick policy.xml file requires modification:
- Locate the
policy.xml file: The location varies depending on the ImageMagick version and operating system. Common paths include /etc/ImageMagick-6/policy.xml or /etc/ImageMagick-7/policy.xml.
Edit the policy.xml file: Open the file with administrative privileges using a text editor (e.g., sudo nano /etc/ImageMagick-6/policy.xml).
- Modify the PDF policy: Find the line that restricts PDF access, typically looking like this:
Code
<policy domain="coder" rights="none" pattern="PDF" />
Change rights="none" to rights="read|write" to allow both reading and writing of PDF files:
<policy domain="coder" rights="read|write" pattern="PDF" />
Alternatively, if a newer, patched version of Ghostscript (9.24 or later) is installed, the entire section disabling Ghostscript-handled types can be removed if desired, though modifying just the PDF policy is sufficient for this error.
- Restart PHP-FPM or your web server: After saving the changes to policy.xml, restart your PHP-FPM service (e.g., sudo service php7.x-fpm restart) or your web server (e.g., Apache or Nginx) for the changes to take effect.
Feel free to delete the test dir unless there is something else I need to diagnose.