gpt4 book ai didi

php - 在 Travis 上使用 php-imagick 阅读 pdf 文件

转载 作者:搜寻专家 更新时间:2023-10-31 21:19:28 32 4
gpt4 key购买 nike

我需要在 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

最佳答案

过了一会儿我才回答我自己的问题:

问题是 imagemagick 需要 ghostscript 来处理 pdf,而 ghostscript 需要在 Debian 中安装。

因此,除了编辑 policy.xml 文件之外,将安装命令添加到 .travis.yml 也可以达到目的。

sudo apt-get install -y ghostscript

完整的 travis 文件是:https://github.com/ivoba/silverstripe-simple-pdf-preview/blob/master/.travis.yml

关于php - 在 Travis 上使用 php-imagick 阅读 pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57216391/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com