Created
April 23, 2011 17:49
-
-
Save flags/938826 to your computer and use it in GitHub Desktop.
imgblend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, Image | |
size = 328, 328 | |
outdir='D:\\pics\\thumbs' | |
files = [] | |
glob = None | |
try: | |
for root, dirs, files in os.walk("%s" % (sys.argv[1])): | |
for infile in files: | |
_fname = os.path.join(root, infile) | |
files.append(_fname) | |
except: | |
print 'imgblend.py <dir>' | |
try: | |
for _fname in files: | |
file, ext = os.path.splitext(_fname) | |
if ext=='.jpg': | |
try: | |
if glob == None: | |
glob = Image.open(_fname) | |
else: | |
img = Image.open(_fname) | |
glob = Image.blend(glob,img,0.0) | |
except: | |
print 'Can\'t open image.' | |
#outfile = os.path.splitext(infile)[0] + ".thumbnail" | |
#if infile != outfile: | |
# try: | |
# im = Image.open(infile) | |
# im.thumbnail(size) | |
# im.save(outfile, "JPEG") | |
# except IOError: | |
# print "cannot create thumbnail for", infile | |
except: | |
print 'Something went wrong!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment