In certain instances, attempts to convert a PDF to an image using ImageMagick via the subprocess package may encounter an error that reads:
convert-im6.q16: not authorized `temp2.pdf' @ error/constitute.c/ReadImage/412.
This error indicates that ImageMagick lacks the necessary authorization to access the PDF file. To resolve this issue, follow the steps outlined below:
Open the ImageMagick policy file located at /etc/ImageMagick-6/policy.xml.
Locate and uncomment the following line:
<!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
Change the value of "rights" from "none" to "read|write":
<policy domain="module" rights="read|write" pattern="{PS,PDF,XPS}" />
Note: On some systems, the policy line may use "domain="coder"" instead of "domain="module"."
Save the changes to the policy file and restart ImageMagick. The specific command to restart ImageMagick varies depending on the platform you are using.
By executing these steps, you will grant ImageMagick the necessary authorization to access and convert the PDF file.
The above is the detailed content of How to Fix ImageMagick\'s \'not authorized\' Error When Converting PDFs?. For more information, please follow other related articles on the PHP Chinese website!