我想将pdf文件转换为图片。我想指定图像的输出维度。我该怎么做?
import subprocess
#I want to pass output dimension as parameter. How do I do that
params = ['convert','./data/in.pdf','thumnails.jpg']
subprocess.check_call(params)
答案 0 :(得分:1)
虽然我并不真正使用image-magick
或convert
命令行命令。但我做了一些研究,发现你可以使用-resize
参数来调整图像大小。您可以参考here和here以及here了解详情。要将其合并到从subprocess
开始运行,您可以执行以下操作:
import subprocess
#I want to pass output dimension as parameter. How do I do that
params = ['convert','./data/in.pdf','-resize', '100x100', 'thumnails.jpg'] # replace 100x100 with your width x height
subprocess.check_call(params)
或者,您可以尝试使用-density
参数:
params = ['convert', '-density', '100x100', './data/in.pdf', 'thumnails.jpg'] # replace 100x100 with your width x height