Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- from PIL import Image
- from PIL import ImageFont
- from PIL import ImageDraw
- width, height = (1000, 500) #<--- Image dimensions, CUSTOMIZE THIS!
- def chop(object,length):
- return [object[i:i+length] for i in range(0, len(object), length)]
- def recur2(object, amt):
- p1 = []
- p2 = []
- p3 = []
- p4 = []
- p5 = []
- for i in range(amt):
- p1.append(object[0])
- p2.append(object[1])
- p3.append(object[2])
- p4.append(object[3])
- p5.append(object[4])
- result = []
- for i in p1:
- result.append(i)
- for i in p2:
- result.append(i)
- for i in p3:
- result.append(i)
- for i in p4:
- result.append(i)
- for i in p5:
- result.append(i)
- return result
- def comma(x):
- if type(x) not in [int, long]:
- raise TypeError("x must be a valid integer")
- if x < 0:
- return '-' + comma(-x)
- f = ''
- while x >= 1000:
- x, r = divmod(x, 1000)
- f = ",%03d%s" % (r, f)
- return "%d%s" % (x, f)
- def colfhex(value):
- lv = len(value)
- return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))
- try:
- b = hashlib.md5(raw_input(">>>")).hexdigest()
- hexy_bits = chop(b, 6)[:-1]
- remainder = chop(b, 6)[-1:]
- color_pallet = [colfhex(i) for i in hexy_bits]
- colordata = recur2(color_pallet, width/5)
- img = Image.new('RGB', (width,height), "white")
- img.putdata(colordata*height)
- draw = ImageDraw.Draw(img)
- font = ImageFont.truetype("arial.ttf", 50)
- draw.text((0, 0),"+"+remainder[0],(255,255,255),font=font)
- img.show()
- except IndexError: print "Input too short! Must be greater than 6 characters."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement