Skip to content

Instantly share code, notes, and snippets.

@tbhaxor
Forked from DoMINAToR98/bojack.py
Created August 20, 2019 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbhaxor/bcdd586b55e81fc75750a28a210ea09b to your computer and use it in GitHub Desktop.
Save tbhaxor/bcdd586b55e81fc75750a28a210ea09b to your computer and use it in GitHub Desktop.
from PIL import Image
import binascii
import string
def rgb2hex(r,g,b):
hex = "#{:02x}{:02x}{:02x}".format(r,g,b)
return str(hex)
im = Image.open('bojack.png')
print im
arr=''
pix_val = list(im.getdata())
for idx,val in enumerate(pix_val):
# print rgb2hex(val[0],val[1],val[2])
if(rgb2hex(val[0],val[1],val[2])=="#078401"):
arr+='0';
else:
arr+='1';
# print arr
n = int(arr, 2)
f = open("bo.jpeg", "w") #writing as output
f.write(binascii.unhexlify('%x' % n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment