I want to convert pdf file to image. I want to specify the output dimension for images. How do I do that?
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)
Although I don't really use image-magick
nor its convert
command-line command. But I done some researching and found out you can use the -resize
parameter to resize images. You can refer back to here and here and also here for more details. To incorporate it to running from subprocess
, you can do:
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)
Alternatively, you can try using the -density
argument:
params = ['convert', '-density', '100x100', './data/in.pdf', 'thumnails.jpg'] # replace 100x100 with your width x height