HartyBart opened this issue on Aug 03, 2021 ยท 23 posts
adp001 posted Wed, 04 August 2021 at 10:10 PM
HartyBart posted at 10:06PM Wed, 04 August 2021 - #4424562
Well, this is as far as I've got so far. I can see why people don't want to work with ImageMagick - it seems so difficult to get the arguments accepted and encapsulated correctly in the Python. This still isn't working, but I think it's the closest I've come yet. I just don't know how to get past this...
import subprocess path = [r'C:|Program Files|ImageMagick|mogrify.exe'] args = ['mogrify -layers "optimize" -fuzz 7% test.gif'] cmd = path + args run_cmd = subprocess.call(cmd, shell=True)
Not tested in Windows, but maybe you want to give this a try:
import subprocess
command = ["ls", "-l"]
try:
output = subprocess.check_output(command, stderr=subprocess.STDOUT).decode()
success = True
except subprocess.CalledProcessError as e:
output = e.output.decode()
success = False
print(output)
The commandstring above has two parts. The command itself ("ls") and an argument ("-l"). Change it to a command you want to try.