将PDF转换为TIFF,600dpi和jpg 96 dpi

时间:2013-02-14 05:32:08

标签: python linux imagemagick

我想使用ImageMagick将pdf转换为600 dpi的tiff和来自Python脚本的96 dpi的jpg。

我使用(imagemagick)命令行完成了这项任务,但我想在python中使用Imagemagick将pdf转换为tiff和jpg,

你可以帮助我......

2 个答案:

答案 0 :(得分:2)

使用PythonMagick

import PythonMagick

img = PythonMagick.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')  

答案 1 :(得分:1)

您可以使用 subprocess module 执行imagemagick命令

import subprocess
params = ['convert', "Options", 'pdf_file', 'thumb.jpg']
subprocess.check_call(params)