Home >Backend Development >Python Tutorial >How to Fix ImageMagick\'s \'not authorized\' Error When Converting PDFs?

How to Fix ImageMagick\'s \'not authorized\' Error When Converting PDFs?

Barbara Streisand
Barbara StreisandOriginal
2024-11-25 06:56:15861browse

How to Fix ImageMagick's

ImageMagick Conversion Issue: Lack of Authorization

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:

  1. Modify the ImageMagick Policy File:

Open the ImageMagick policy file located at /etc/ImageMagick-6/policy.xml.

  1. Uncomment and Modify the Policy Line:

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"."

  1. Save and Restart ImageMagick:

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn