【发布时间】:2017-05-31 13:24:36
【问题描述】:
在 python 3.6、windows 10 上将 pdf 文件转换为 png 的代码我遇到了很多麻烦。
我知道你要说什么:google it!
但我发现的几乎所有内容都在 python 2.7 上。而且有些包还没有更新。
到目前为止,我所看到的最好的方法是使用 Wand,对吗? (我之前安装过ImageMagick)
from wand.image import Image
# Converting first page into JPG
with Image(filename='0.pdf') as img:
img.save(filename="/temp.jpg")
# Resizing this image
这是我的第二个错误:
wand.exceptions.DelegateError: PDFDelegateFailed
`The system cannot find the file specified.' @ error/pdf.c/ReadPDFImage/809
所以我读到我需要 ghostscript。我安装了它。但该软件包适用于 python 2.7,它不起作用。我发现 python3-ghostscript 0.5.0。 https://pypi.python.org/pypi/python3-ghostscript/0.5.0
新错误:
RuntimeError: Can not find Ghostscript DLL in registry
所以在这里我需要安装 Ghostscript 9: https://www.ghostscript.com/download/gsdnld.html
首先,它不是 GPL 许可证……它甚至不是一个包,而是一个程序。我不知道如何在我的未来 python 代码中使用它...
还有一个错误:
RuntimeError: Can not find Ghostscript DLL in registry
我找不到任何东西。
【问题讨论】:
标签: pdf png ghostscript python-3.6 wand