From Python3, I need to call application and pass it several arguments, one of which is
700x500\>
So I do this:
rule_template=r"{}x{}{}"
factor = r"\>"
rule = rule_template.format(700,500,factor)
cmd = ["mogrify", "-resize", rule]
for file in os.listdir(folder):
if file.endswith(".jpg") or file.endswith(".png"):
ff = os.path.join(folder, file)
subprocess.check_call(cmd + [ff])
And the application fails because the argument it recieves looks like
700x500\\>
How to avoid double slashes in the output. Again, it is not an "on screen only" feature, the application I call recieves wrong command.
Here is the full function that fails.
This is the error line:
subprocess.CalledProcessError: Command '['mogrify', '-resize', '100x5\\>', '/tmp/111/de0b8660-b132-4874-b898-1ab4d4a24375/001.jpg']' returned non-zero exit status 1.
If I replace the "factor" variable with empty ""
, application works, but does not do what I need it to.
Application usage example:
mogrify -resize 100x5\> 001.jpg