Skip to content

Instantly share code, notes, and snippets.

@flags
Created April 23, 2011 17:49
Show Gist options
  • Save flags/938826 to your computer and use it in GitHub Desktop.
Save flags/938826 to your computer and use it in GitHub Desktop.
imgblend
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