gpt4 book ai didi

Python将pdf转换为图像?

转载 作者:太空宇宙 更新时间:2023-11-03 10:58:23 25 4
gpt4 key购买 nike

所以我正在使用 Wand 尝试将 pdf 转换为图像

from wand.image import Image

with Image(filename="test.pdf") as img:
img.save(filename="/temp.jpg")

with Image(filename="test.jpg") as img:
img.resize(200, 150)
img.save(filename="t.jpg")

但出于某种原因我得到:

Traceback (most recent call last):
File "C:\Users\Rafael\Desktop\k\pdf to image.py", line 3, in <module>
with Image(filename="test.pdf") as img:
File "C:\Python27\lib\site-packages\wand\image.py", line 2534, in __init__
self.read(filename=filename, resolution=resolution)
File "C:\Python27\lib\site-packages\wand\image.py", line 2601, in read
self.raise_exception()
File "C:\Python27\lib\site-packages\wand\resource.py", line 222, in raise_exception
raise e
DelegateError: PDFDelegateFailed `The system cannot find the file specified.

' @ error/pdf.c/ReadPDFImage/798

我可以做些什么吗?或者有其他方法可以将 pdf 转换为图像吗?

最佳答案

安装 Ghostscript 并添加

C:\Program Files (x86)\gs\gs9.06\bin

到您的 systempath 应该有助于解决这个问题,因为它帮助我克服了这个错误....

关于Python将pdf转换为图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37299666/

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