Created
July 3, 2019 16:33
-
-
Save DoMINAToR98/59c3cc9b80e1c733aaf253d94196db76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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