jack
jack

Reputation: 17881

How to pass this command to subprocess.call?

Command:

root@host:~#convert source.jpg -resize x500 -resize "500x<" -gravity center +repage target.jpg

Python code:

>> command_list = ['convert', 'source.jpg', '-resize', 'x500', '-resize', '\'500x<\'', '-gravity', 'center', 'target.jpg']
>> p = subprocess.call(command_list)
convert: invalid argument for option `'500x<'': -resize.

What's wrong in above code?

Upvotes: 2

Views: 3244

Answers (2)

gahooa
gahooa

Reputation: 137312

Why the extra quotes on 500x<? Subprocess will correctly quote any arguments.

Keep in mind that the shell will NOT pass the outer quotes to the application, just the quoted value, but subprocess will pass the quotes if you force it to.

Upvotes: 5

Davide
Davide

Reputation: 17818

Have you tried '"500x<"' instead of '\'500x<\''?

Upvotes: 0

Related Questions