我想使用 ImageMagick 从 Python 脚本将 pdf 转换为 600 dpi 的 tiff 和 96 dpi 的 jpg。
我使用(imagemagick)命令行完成了这项任务,但我想使用python中的Imagemagick将pdf转换为tiff和jpg,
你能帮我吗......
首先,您必须加载 imagemagick 库的包装器
using PythonMagick https://www.imagemagick.org/download/python/:
from PythonMagick import Image
或使用pgmagick https://pypi.org/project/pgmagick/:
from pgmagick import Image
然后,独立于您加载的库,以下代码将转换图像并调整图像大小
img = Image()
img.density('600') # you have to set this here if the initial dpi are > 72
img.read('test.pdf') # the pdf is rendered at 600 dpi
img.write('test.tif')
img.density('96') # this has to be lower than the first dpi value (it was 600)
# img.resize('100x100') # size in px, just in case you need it
img.write('test.jpg')
# ... same code as with pythonmagick
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)