Advertisement
Peaser

anyarg

Jul 31st, 2014
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. from PIL import Image
  2. import math, sys
  3.  
  4. try:
  5.     use = sys.argv[1] #Usage: Python anyarg.py <path>
  6. except Exception, e: print e
  7.  
  8. try:
  9.  
  10.     data = open(use, 'rb').read().encode('base64')
  11.     parts = [ord(i) for i in data] #all base64 characters fit in the ordinal range (which goes up to 256)
  12.     vecs = [(i, i, i) for i in parts] #turning i into (i, i, i)
  13.  
  14.     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
  15.     img.putdata(vecs) #putting (i, i, i) on to the image
  16.     img.show() #result
  17.  
  18. except Exception, e: print e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement