Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python子流程中指定图像输出的维度?_Python_Imagemagick_Subprocess_Imagemagick Convert - Fatal编程技术网

如何在python子流程中指定图像输出的维度?

如何在python子流程中指定图像输出的维度?,python,imagemagick,subprocess,imagemagick-convert,Python,Imagemagick,Subprocess,Imagemagick Convert,我想将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) 虽然我没有真正使用imagemagick或者它的convert命令行命令。但是我做了一些研究,发现可

我想将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) 

虽然我没有真正使用
imagemagick
或者它的
convert
命令行命令。但是我做了一些研究,发现可以使用
-resize
参数来调整图像大小。有关更多详细信息,请参阅和。要将其合并到从
子流程运行
,可以执行以下操作:

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 

convert
是image-magick命令行程序。
-resize
不起作用,但
-density
参数起作用。可能是因为输入是pdf文件。哈哈,就像我说的,我不使用那个工具。。。但我可以找到链接:),无论如何,很高兴你找到了解决方案。