Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import math, sys
- try:
- use = sys.argv[1] #Usage: Python anyarg.py <path>
- except Exception, e: print e
- try:
- data = open(use, 'rb').read().encode('base64')
- parts = [ord(i) for i in data] #all base64 characters fit in the ordinal range (which goes up to 256)
- vecs = [(i, i, i) for i in parts] #turning i into (i, i, i)
- img = Image.new('RGB', (int(math.ceil(math.sqrt(len(vecs)))), int(math.ceil(math.sqrt(len(vecs))))), "white") #Making the image square, aswell as *just* large enough to have leftover space
- img.putdata(vecs) #putting (i, i, i) on to the image
- img.show() #result
- except Exception, e: print e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement