Created
July 24, 2011 03:23
-
-
Save arthurnn/1102182 to your computer and use it in GitHub Desktop.
threadless wallpaper
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
from PIL import Image | |
import urllib | |
import cStringIO | |
import re | |
import sys | |
URL = sys.argv[1] | |
ratio = 1 | |
size = (1440,900) | |
reg = 'm|^http://.*threadless.*/(\d+)/([^/]+)|' | |
m = re.search(reg, URL) | |
pid = m.group(1) | |
URL = "http://media.threadless.com/product/%s/zoom.gif" % pid | |
file = urllib.urlopen(URL) | |
im = cStringIO.StringIO(file.read()) | |
img = Image.open(im) | |
img = img.resize( [int(ratio * s) for s in img.size],Image.ANTIALIAS ) | |
place = (((size[0] - img.size[0])/2,(size[1] - img.size[1])/2)) | |
bg = img.crop((0,0,1,1)) | |
bg = bg.resize(size) | |
bg.paste(img,place) | |
bg.save('background.png','png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment