from PIL import Image #exemple input = "carre_base_encode.png" input = "tentacle_image_encode_4.png" imagette1_noir = [ [ [0,255,0,0], [0,255,255,255], [255,255,255,0], [0,0,255,0], ], [ [0,255,255,255], [255,255,255,0], [0,0,255,0], [0,255,0,0], ], [ [255,255,255,0], [0,0,255,0], [0,255,0,0], [0,255,255,255], ], [ [0,0,255,0], [0,255,0,0], [0,255,255,255], [255,255,255,0], ], [ [255,0,0,0], [255,255,255,0], [255,255,0,255], [0,255,0,0], ], [ [0,0,0,255], [255,255,0,255], [255,0,255,255], [255,0,0,0], ], [ [0,0,255,0], [255,0,255,255], [0,255,255,255], [0,0,0,255], ], ] imagette2_noir = [ [ [0,0,255,0], [255,255,255,0], [0,255,255,255], [0,255,0,0], ], [ [255,255,255,0], [0,255,255,255], [0,255,0,0], [0,0,255,0], ], [ [0,255,255,255], [0,255,0,0], [0,0,255,0], [255,255,255,0], ], [ [0,255,0,0], [0,0,255,0], [255,255,255,0], [0,255,255,255], ], [ [0,255,0,0], [255,255,0,255], [255,255,255,0], [255,0,0,0], ], [ [255,0,0,0], [255,0,255,255], [255,255,0,255], [0,0,0,255], ], [ [0,0,0,255], [0,255,255,255], [255,0,255,255], [0,0,255,255], ], ] noir = imagette1_noir + imagette2_noir input_image = Image.open(input) width, height = input_image.size output_image = Image.new(input_image.mode, (int(width)//4, int(height)//4)) for x in range(0, width, 4): for y in range(0, height, 4): if x == 4 and y == 4: z=1 imagette = [ [input_image.getpixel((x, y)), input_image.getpixel((x+1, y)), input_image.getpixel((x+2, y)), input_image.getpixel((x+3, y))], [input_image.getpixel((x, y+1)), input_image.getpixel((x+1, y+1)), input_image.getpixel((x+2, y+1)), input_image.getpixel((x+3, y+1))], [input_image.getpixel((x, y+2)), input_image.getpixel((x+1, y+2)), input_image.getpixel((x+2, y+2)), input_image.getpixel((x+3, y+2))], [input_image.getpixel((x, y+3)), input_image.getpixel((x+1, y+3)), input_image.getpixel((x+2, y+3)), input_image.getpixel((x+3, y+3))], ] if imagette in noir: output_image.putpixel((x//4, y//4), 0) # print("NOIR", imagette) else: output_image.putpixel((x//4, y//4), 1) # print("BLANC", imagette) output_image.show() "Tux", "Gnu", "Beastie", "Adiumy"