ImageMagick not authorized to convert PDF to an image

前端 未结 4 999
误落风尘
误落风尘 2020-11-22 06:01

I have a program, in which I need to convert a PDF to an image using Image Magick. I do that using the subprocess package:

        cmd = \'magic         


        
相关标签:
4条回答
  • 2020-11-22 06:36

    I am using Dockerfile to update an image, and suddenly I got the policy.xml file in my way. although the version of Ubuntu (xenial) was the same and ImageMagick as well.

    I ended up removing the single line causing my problem.

    RUN sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml

    hope this helps someone

    0 讨论(0)
  • 2020-11-22 06:37

    Use the below command to delete the policy file to fix it, If required you can also take backup of this policy file.

    rm /etc/<ImageMagick_PATH>/policy.xml
    

    for me it was ImageMagick6 and the command was :

    sudo rm /etc/ImageMagick-6/policy.xml
    
    0 讨论(0)
  • 2020-11-22 06:44

    emcconville is correct. More specifically edit the Imagemagick policy.xml file to uncomment this line:

      <!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
    


    And change it from rights="none" to rights="read|write"

      <policy domain="module" rights="read|write" pattern="{PS,PDF,XPS}" />
    


    This was a recent addition to the policy.xml file, I believe, due to a security flaw found in the Ghostscript delegate. I think that flaw has now been fixed in the current version of Ghostscript, which is 9.25.

    NOTE: On some systems the policy line will have domain="coder" rather than domain="module"

    0 讨论(0)
  • 2020-11-22 06:44

    Quick and easy solution:

    sudo mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.off
    

    When done, you can restore the original with

    sudo mv /etc/ImageMagick-6/policy.xml.off /etc/ImageMagick-6/policy.xml
    
    0 讨论(0)
提交回复
热议问题