I asked ChatGPT to give me the python code.
And then I compiled it into windows exe file as onefile and zipped it up but can't attach it because the zip is 10Mb
I wonder if there's other way to send that to you
you'll just have to name your image as "image.png" and put it in same folder as the exe and execute the exe and it'll make an xlsx file that is where each cell has the color of the pixels.
Python code.
from PIL import Image
import openpyxl
from openpyxl.styles import PatternFill
# Load your image
image_path = "image.png"
img = Image.open(image_path)
img = img.convert("RGB") # Ensure image is RGB
# Create an Excel workbook and sheet
wb = openpyxl.Workbook()
ws = wb.active
# Set a reasonable max size for large images
max_size = (50, 50)
img.thumbnail(max_size)
# Iterate through each pixel in the image
for y in range(img.height):
for x in range(img.width):
# Get pixel color
r, g, b = img.getpixel((x, y))
# Convert RGB to hex
hex_color = f"{r:02x}{g:02x}{b:02x}"
# Set cell background color
cell = ws.cell(row=y + 1, column=x + 1)
cell.fill = PatternFill(start_color=hex_color, end_color=hex_color, fill_type="solid")
# Save Excel file
wb.save("image_as_excel.xlsx")