Advertisement
Peaser

SQUARED imgtrans

Jul 2nd, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from PIL import Image
  2. import sys, binascii, hashlib, os, pprint, math, random
  3.  
  4. path = "dot.png"
  5.  
  6. imgdata = open(path,'rb').read().encode('base64')
  7. hue = str(imgdata)
  8. value = bin(int(binascii.hexlify(hue), 16)).replace('b','')
  9. cmap = {'0': (255,255,255),'1': (0,0,0)}
  10. data2 = [cmap[letter] for letter in value]
  11. dim = int(math.ceil(math.sqrt(len(value))))
  12. img = Image.new('RGB', (dim, dim), "white")
  13. img.putdata(data2)
  14. desktoppath = os.path.expanduser("~/Desktop/")
  15. img.save(desktoppath+'Item.bmp')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement