5 nouveaux défis
This commit is contained in:
24
L'écharpe de Mme Weasley.py
Normal file
24
L'écharpe de Mme Weasley.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from PIL import Image
|
||||
|
||||
image = Image.open("L'écharpe de Mme Weasley.png")
|
||||
#image = Image.open("L'écharpe de Mme Weasley_exemple.png")
|
||||
|
||||
block = 8
|
||||
|
||||
width, height = image.size
|
||||
|
||||
xmax = width // block
|
||||
ymax = height // block
|
||||
|
||||
res = ""
|
||||
|
||||
for x in range(xmax):
|
||||
for y in range(ymax):
|
||||
colors = {}
|
||||
for i in range(block):
|
||||
for j in range(block):
|
||||
pixel = image.getpixel((x*block+i,y*block+j))
|
||||
colors[pixel] = None
|
||||
res = res + f"{len(colors)-1:1X}"
|
||||
|
||||
print(bytearray.fromhex(res).decode())
|
||||
Reference in New Issue
Block a user