Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. import os
  2. import shutil
  3.  
  4.  
  5. # Settings
  6. n, m = 6, 6
  7. input_folder = "input"
  8. tmp_folder = "tmp"
  9. output_image = "combined_image.png"
  10. size = 300
  11.  
  12. # Remove existing folder
  13. if os.path.exists(tmp_folder):
  14. shutil.rmtree(tmp_folder)
  15. os.mkdir(tmp_folder)
  16.  
  17. # Resize images
  18. os.system("mogrify -resize %ix%i -quality 100 -path %s %s" % \
  19. (size, size, tmp_folder, os.path.join(input_folder, "*.png")))
  20.  
  21. # Combine images
  22. command = "convert "
  23. input_files = [path for path in os.listdir(tmp_folder)]
  24.  
  25. for i in range(n):
  26. command += "( "
  27. for j in range(m):
  28. command += os.path.join(tmp_folder, input_files[i*m + j]) + " "
  29. command += "+append ) "
  30. command += ("-append %s" % output_image)
  31.  
  32. print(command)
  33. os.system(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement