Skip to content

Is it possible to change ImageMagick policy? #155

Open
@mgeier

Description

@mgeier

When trying to convert a PDF file to PNG, I get the following error:

RuntimeError: Error running 'convert -density 96 /tmp/magic_call-rrtbdrjl/magic_call.pdf /tmp/magic_call-rrtbdrjl/magic_call.pdf.png' to create 'magic_call.pdf.png':
convert-im6.q16: not authorized `/tmp/magic_call-rrtbdrjl/magic_call.pdf' @ error/constitute.c/ReadImage/412.
convert-im6.q16: no images defined `/tmp/magic_call-rrtbdrjl/magic_call.pdf.png' @ error/convert.c/ConvertImageCommand/3258.

This seems to be due to a security problem that has been fixed in the meantime but a safety mechanism has not been reverted (AFAIU, but I don't really understand the details).

The suggested fix is to change the file /etc/ImageMagick-6/policy.xml from having the line

<policy domain="coder" rights="none" pattern="PDF" />

to the line

<policy domain="coder" rights="read" pattern="PDF" />

Here are some links that I have found:

https://www.scivision.dev/imagemagick-convert-not-authorized/
https://stackoverflow.com/questions/53377176/change-imagemagick-policy-on-a-dockerfile

https://stackoverflow.com/questions/52861946/imagemagick-not-authorized-to-convert-pdf-to-an-image
https://askubuntu.com/questions/1081895/trouble-with-batch-conversion-of-png-to-pdf-using-convert
https://stackoverflow.com/questions/42928765/convertnot-authorized-aaaa-error-constitute-c-readimage-453

Is it possible to fix this in the docker image?

An alternative to fixing this would be to install poppler-utils instead: #154.

Ideally both things could be done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions