Lenna

Lenna

Découvre le message de Lenna.

Besoin d’un indice?

import urllib
from PIL import Image

def decode_image(img):
  width, height = img.size
  msg = ""
  index = 0
  for row in range(height):
      for col in range(width):
          r, g, b = img.getpixel((col, row))
          if row == 0 and col == 0:
              msg_length = r
          elif index <= msg_length:
              msg += chr(r)
          index += 1
  return msg

urllib.urlretrieve("https://www.cedricbonhomme.org/images/blog/2014/08/Lenna_Simple_Method.png", "Lenna.png")
img = Image.open("Lenna.png")
print decode_image(img)

Posts in this series

Related Posts