Skip to content Skip to sidebar Skip to footer

How To Run Imagemagick In The Background From Python

How can you use imagemagick from python without opening a new command line window and losing focus? This loop show the problem; the system becomes unusable while working on images

Solution 1:

subprocesses.Popen is the recommended way to do it:

# Start all the processes.
processes = []
for i in range(100):
    p = subprocess.Popen(['convert', '-background', 'black', '-fill', 'white', '-font', 'arial', '-size', '50x50', '-encoding', 'utf8', '-gravity', 'center', 'caption:"just stole your focus"', 'C:/testFile.png'])
    processes.append(p)

# Wait for all the processes to finish.
for p in processes:
    p.wait()

Post a Comment for "How To Run Imagemagick In The Background From Python"