Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import sys, binascii, hashlib, os, pprint, math, random
- path = "dot.png"
- imgdata = open(path,'rb').read().encode('base64')
- hue = str(imgdata)
- value = bin(int(binascii.hexlify(hue), 16)).replace('b','')
- cmap = {'0': (255,255,255),'1': (0,0,0)}
- data2 = [cmap[letter] for letter in value]
- dim = int(math.ceil(math.sqrt(len(value))))
- img = Image.new('RGB', (dim, dim), "white")
- img.putdata(data2)
- desktoppath = os.path.expanduser("~/Desktop/")
- img.save(desktoppath+'Item.bmp')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement