您好,我正在结合使用 python 和imagemagick将 pdf 转换为图像(jpeg)。我安装了 ImageMagick 和 Python Wand 模块。
当我在 Windows 10 中运行脚本时,它运行完美,但是当我在 Ubuntu 20.xx 下运行它时,我收到以下错误作为响应:
回溯(最近一次调用):文件“wandExample.py”,第 2 行,pdf = wi(filename="data/Lucas_Mur.pdf", resolution=300) 文件“/home/erik_hoeven/.local/lib/python3 .8/site-packages/wand/image.py”,第 8636 行,在init self.read(filename=filename) 文件“/home/erik_hoeven/.local/lib/python3.8/site-packages/wand/image .py”,第 9230 行,读取 self.raise_exception() 文件“/home/erik_hoeven/.local/lib/python3.8/site-packages/wand/resource.py”,第 230 行,在 raise_exception raise e wand。 exceptions.MissingDelegateError:没有此图像格式的解码委托`'@error/constitute.c/ReadImage/562
from wand.image import Image as wi
pdf = wi(filename="data/Lucas_Mur.pdf", resolution=300)
pdfimage = pdf.convert("jpeg")
i=1
for img in pdfimage.sequence:
page = wi(image=img)
page.save(filename=str(i)+".jpg")
i +=1
为了在 Ubuntu 20.xxx 下安装 ImageMagick,我执行了以下语句:
sudo apt update
sudo apt-get install build-essential
wget https://www.imagemagick.org/download/ImageMagick.tar.gz
tar xvzf ImageMagick.tar.gz
./configure`
make
sudo make install
sudo ldconfig /usr/local/lib
sudo apt-get install -y ghostscript-x
当我使用magick -version
结果测试 imagemagick 时:
版本:ImageMagick 7.0.10-31 Q16 x86_64 2020-09-27 https://imagemagick.org版权所有:© 1999-2020 ImageMagick Studio LLC 许可证:https ://imagemagick.org/script/license.php功能:密码 DPC HDRI OpenMP(4.5) 代表(内置): bzlib djvu fontconfig freetype jbig jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib
当我执行 imagemagick 命令时,我也收到一条错误消息:
convert Lucas_Mur.pdf Output.jpg
转换:此图像格式没有解码委托
' @ error/constitute.c/ReadImage/562. convert: no images defined
Output.jpg'@error/convert.c/ConvertImageCommand/3285。
你能帮忙解决这个错误并解释为什么我收到这个!