Imagemagick - change policy.xml on Heroku

别来无恙 提交于 2019-12-07 22:38:00

问题


I'm trying to access images via https on Heroku with Imagemagick. How can I change the policies (in policy.xml) on Heroku?

Heroku made an "ImageMagick security update" in May, 2016: https://devcenter.heroku.com/changelog-items/891

I can see the policy list, after typing heroku run bash and convert -list policy:

Path: [built-in] Policy: Undefined rights: None

Path: /etc/ImageMagick/policy.xml [...] Policy: Coder rights: None pattern: HTTPS [...]

How can I change the policy?

update 1: this is the error in the log file:

Command failed: convert.im6: not authorized `//scontent-fra3-1.xx.fbcdn.net/v/t1.0-9/13962741_132344500547278_4974691444630710043_n.jpg?oh=c169b4ffce9e5ce330ee99214cc6b8d5&oe=5880F245'


回答1:


I’ve found a relatively simple solution.

Create a .magick directory in your app’s source, and add your policy.xml there. Then, you’ll have to set the environment variable MAGICK_CONFIGURE_PATH to /app/.magick in order to load your file with higher precedence than the default one.




回答2:


We need to install the third party software ImageMagick on heroku. I used this https://github.com/ello/heroku-buildpack-imagemagick build pack for installing ImageMagick.

So, inside bin/compile, there is a policy file, which is restricting the images to read over Https, enable the attribute rights to read which allows to read over Https

Fork the repo and do your changes, commit and add that repository url to your heroku buildpacks




回答3:


Read the warnings at ImageTragick, then make a backup and delete the line that restricts you.

You can find the file to edit in the same directory as the other XML config files by doing the following - the file is called policy.xml:

convert -debug configure -list font 2>&1 | grep -E "Searching|Loading"


来源:https://stackoverflow.com/questions/39425446/imagemagick-change-policy-xml-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!