from PIL import Image

im = Image.open("IUT_RT_STEG.png").convert('RGBA')

width, height = im.size

red, green, blue, alpha = im.split()

s = ""
for y in range(55):
    for x in range(width):
       a = alpha.getpixel((x,y))
       if a == 254:
           s=s+str(blue.getpixel((x,y))%2)
       if a == 253:
           s=s+str(green.getpixel((x,y))%2)
       if a == 252:
           s=s+str(red.getpixel((x,y))%2)
       if a == 251:
           s=s+str(blue.getpixel((x,y))%2)+str(green.getpixel((x,y))%2)
       if a == 250:
           s=s+str(blue.getpixel((x,y))%2)+str(red.getpixel((x,y))%2)
       if a == 249:
           s=s+str(green.getpixel((x,y))%2)+str(blue.getpixel((x,y))%2)
       if a == 248:
           s=s+str(green.getpixel((x,y))%2)+str(red.getpixel((x,y))%2)
       if a == 247:
           s=s+str(red.getpixel((x,y))%2)+str(blue.getpixel((x,y))%2)
       if a == 246:
           s=s+str(red.getpixel((x,y))%2)+str(green.getpixel((x,y))%2)
       if a == 245:
           s=s+str(blue.getpixel((x,y))%2)+str(green.getpixel((x,y))%2)+str(red.getpixel((x,y))%2)
       if a == 244:
           s=s+str(blue.getpixel((x,y))%2)+str(red.getpixel((x,y))%2)+str(green.getpixel((x,y))%2)
       if a == 243:
           s=s+str(green.getpixel((x,y))%2)+str(blue.getpixel((x,y))%2)+str(red.getpixel((x,y))%2)
       if a == 242:
           s=s+str(green.getpixel((x,y))%2)+str(red.getpixel((x,y))%2)+str(blue.getpixel((x,y))%2)
       if a == 241:
           s=s+str(red.getpixel((x,y))%2)+str(blue.getpixel((x,y))%2)+str(green.getpixel((x,y))%2)
       if a == 240:
           s=s+str(red.getpixel((x,y))%2)+str(green.getpixel((x,y))%2)+str(blue.getpixel((x,y))%2)

for i in range(len(s)//8):
    val = int(s[i*8+0])*128 + int(s[i*8+1])*64 + int(s[i*8+2])*32 + int(s[i*8+3])*16 + int(s[i*8+4])*8 + int(s[i*8+5])*4 + int(s[i*8+6])*2 + int(s[i*8+7])*1
    c = chr(val)
    print(c, end='')
