「ImageMagick」- 常用命令及常见问题

  CREATED BY JENKINSBOT

常用命令汇总

修改宽度,并保持高度比例

Imagemagick: Convert to fixed width, proportional height – Stack Overflow

使用 -resize 100x 选项

常见问题汇总

attempt to perform an operation not allowed by the security policy `PDF’

ImageMagick security policy ‘PDF’ blocking conversion – Stack Overflow

当执行 convert 命令是,产生如下错误:

# convert -density 300 -depth 8 -quality 90 input.pdf output.png
convert: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408.
convert: no images defined `output.png' @ error/convert.c/ConvertImageCommand/3288.

这是因为 Ghostscript 的 Bug 所以才添加该策略。

通过修改 /etc/ImageMagick-7/policy.xml 文件以解决,添加如下配置行:

...
  <policy domain="coder" rights="read | write" pattern="PDF" />
</policymap>