Skip to content

Instantly share code, notes, and snippets.

@illuzian
Last active August 29, 2015 14:12
Show Gist options
  • Save illuzian/54a083c5a394eae00177 to your computer and use it in GitHub Desktop.
Save illuzian/54a083c5a394eae00177 to your computer and use it in GitHub Desktop.
import json
import urllib
from PIL import Image
import cStringIO
map_data = "https://static.mwomercs.com/data/cw/mapdata.json"
data = json.load(urllib.urlopen(map_data))
images = {}
for x, y in data.iteritems():
if x != 'generated' and int(y['owner']['id']) != 0:
img = y['owner']['icon']
if img not in images:
images[img] = Image.open(cStringIO.StringIO(urllib.urlopen(img).read())).resize((20,20))
map = Image.new("RGB", (1400,1400))
for x, y in data.iteritems():
if x != 'generated' and int(y['owner']['id']) != 0:
map.paste(images[y['owner']['icon']], ((int(y['position']['x'])+700), (-int(y['position']['y'])+700)) )
map.save('test.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment