- 2020-06-30
问题
Manjaro linux 系统下,通过 convert 将pdf 转换为图片时出现如下 the security policy
报错:
$ convert input.pdf output.jpg
convert: attempt to perform an operation not allowed by the security policy `gs' @ error/delegate.c/ExternalDelegateCommand/378.
convert: no images defined `tikz.jpg' @ error/convert.c/ConvertImageCommand/3282.
这个问题表明:Imagemagick 安全策略似乎不允许我执行pdf 转换 jpg。安装 imagemagick 之后,没有对其做过任何设置处理。
解决办法
参考 stackoverflow: https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion
从报错看是 Imagemagick 安全协议不允许 gs
运行,所以去查看 Imagemagick 的安全协议。
在 /etc/ImageMagick-7/
文件夹下找到 policy.xml
文件。文件最后部分,发现 gs
部分未被注释,而 right=none
,是不允许的
<policy domain="delegate" rights="none" pattern="gs" />
将上述部分注释之后,成功将 pdf 转 jpg。
<!-- <policy domain="delegate" rights="none" pattern="gs" /> -->