from PIL import Image

input_file = "input.png"
output_file = "output.txt"

img = Image.open(input_file).convert("RGB")

width, height = img.size
pixels = img.load()

with open(output_file, "w", encoding="utf-8") as f:
    for y in range(height):
        row = []

        for x in range(width):
            r, g, b = pixels[x, y]
            hexcode = f"#{r:02X}{g:02X}{b:02X}"
            row.append(hexcode)

        f.write("\t".join(row) + "\n")

print("done")