Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import sys,os
- dimensions = (1920,1080)
- try:
- workpath = sys.argv[1] #<--THIS NEEDS TO BE A DIRECTORY
- if not os.path.isdir(workpath): raise Exception, "Not a directory."
- except Exception, e:
- print e
- sys.exit(0)
- def avAll(object):
- """LIST OF TUPLES(LEN=3)"""
- a,b,c=[],[],[]
- a.append([i[0] for i in object])
- b.append([i[1] for i in object])
- c.append([i[2] for i in object])
- a = [sum(i)/len(i) for i in a]
- b = [sum(i)/len(i) for i in b]
- c = [sum(i)/len(i) for i in c]
- return (a,b,c)
- files = [i for i in os.listdir(workpath)]
- pix = []
- for i in files:
- pic1 = Image.open(workpath+'/'+i).resize(dimensions)
- p1dat = pic1.getdata()
- pix.append(p1dat)
- vecs = zip(*pix)
- total = [avAll(i) for i in vecs]
- def fix(a):
- t = []
- for i in a:
- t2 = []
- for z in i:
- t2.append(z[0])
- t.append(tuple(t2))
- return t
- total = fix(total)
- img = Image.new('RGB', dimensions, "white")
- img.putdata(total)
- img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement