Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import shutil
- # Settings
- n, m = 6, 6
- input_folder = "input"
- tmp_folder = "tmp"
- output_image = "combined_image.png"
- size = 300
- # Remove existing folder
- if os.path.exists(tmp_folder):
- shutil.rmtree(tmp_folder)
- os.mkdir(tmp_folder)
- # Resize images
- os.system("mogrify -resize %ix%i -quality 100 -path %s %s" % \
- (size, size, tmp_folder, os.path.join(input_folder, "*.png")))
- # Combine images
- command = "convert "
- input_files = [path for path in os.listdir(tmp_folder)]
- for i in range(n):
- command += "( "
- for j in range(m):
- command += os.path.join(tmp_folder, input_files[i*m + j]) + " "
- command += "+append ) "
- command += ("-append %s" % output_image)
- print(command)
- os.system(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement