Add support for avatar overlays

This commit is contained in:
Trever Fischer
2012-04-18 09:56:02 -04:00
parent e72f60596f
commit 1626161f75

View File

@@ -21,7 +21,11 @@ def avatar(request, username, size=64):
skinStream = open(os.path.dirname(__file__)+"/static/skin.png")
imgStream = StringIO(skinStream.read())
img = Image.open(imgStream)
img = img.crop((8, 8, 16,16))
face = img.crop((8, 8, 16,16))
face.load()
overlay = img.crop((40, 8, 48, 16))
overlay.load()
img = Image.composite(overlay, face, overlay)
img = img.resize((size, size), Image.NEAREST)
buf = StringIO()
img.save(buf, "PNG")