Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # Composite generation script using PIL
- import sys
- import os.path
- import PIL
- from PIL import Image
- input_dir = r"C:/unfavorable semicircle/!LockKF/" #Path to directory of key frames
- x = 160 #Initial X
- y = 0 #Initial Y
- width = 197 #Width of the composite image
- height = int(50000/width) #Approxomite height of the image given width
- #Change dividend based on how many images there are
- files = os.scandir(input_dir) #Gets all pictures in directory
- thumbnail_size = (1, 1) #How big each image is in composite
- comp = Image.new("RGB", (width, height), "white") #Creates an image object for composite
- # Loop through all files in dir
- for i in os.listdir(input_dir):
- try:
- # Attempt to open an image file
- image = Image.open(input_dir + i)
- except IOError:
- # Report error, and then skip to the next argument
- print("Problem opening" + " " + i)
- continue
- # Resize the image
- image = image.resize(thumbnail_size, Image.ANTIALIAS)
- # Add image to composite
- comp.paste(image, (x,y))
- print("pasted " + i)
- x+= 1
- if(x == width):
- x = 0
- y+= 1
- # Save the composite as Comp.png in the input directory.
- comp.save(input_dir + 'Comp.png')
- print("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement