【发布时间】:2019-07-26 08:48:33
【问题描述】:
我需要阅读 Travis 上带有 php-imagick 扩展名的 pdf 文件。
我了解到我需要调整 imagick policy.xml 文件以允许 imagick 读取 pdf 文件。 所以我添加了一个自定义 policy.xml。
env:
global:
- MAGICK_CONFIGURE_PATH=$HOME/.config/ImageMagick/
...
before_script:
# Allow imagemagick to read PDF files
- echo $MAGICK_CONFIGURE_PATH
- mkdir $MAGICK_CONFIGURE_PATH
- echo '<policymap>' > $MAGICK_CONFIGURE_PATH/policy.xml
- echo '<policy domain="coder" rights="read" pattern="PDF" />' >> $MAGICK_CONFIGURE_PATH/policy.xml
- echo '</policymap>' >> $MAGICK_CONFIGURE_PATH/policy.xml
- sudo rm /etc/ImageMagick-6/policy.xml
但构建仍然失败,[Failed to read the file]
该文件在那里,在本地可以正常工作,我怀疑 imagick 仍然无法阅读 PDF。 新政策似乎也适用:
$convert -list policy
Path: /home/travis/.config/ImageMagick/policy.xml
Policy: Coder
rights: Read
pattern: PDF
Policy: Coder
rights: Read
pattern: PDF
Path: [built-in]
Policy: Undefined
rights: None
我该如何解决这个问题?
失败的构建是:https://travis-ci.org/ivoba/silverstripe-simple-pdf-preview/jobs/563919021
【问题讨论】:
-
使用 Imagick PHP 使用与 shell 不同的环境变量发送。因此,编辑 delegates.xml 文件并将
gs的完整路径放在使用它的委托行中。 GS 是 Ghostscript。还要确保您已安装 Ghostscript 以供 ImageMagick 使用。 -
是的,同时我还发现 ghostscript 不见了:
- sudo apt-get install -y ghostscript使它工作。随时提出答案。