It is currently Thu Sep 17, 2026 4:25 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Export image as excel
PostPosted: Mon Nov 04, 2024 2:31 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
GIMP Version: 2.10.32
Operating System: Windows
GIMP Experience: New User



Hey....is it possible to export an image to excel so that each pixel is a cell....hope that makes sense? TIA

_________________
Image


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Export image as excel
PostPosted: Mon Nov 04, 2024 4:17 pm  (#2) 
Offline
GimpChat Member

Joined: Sep 26, 2015
Posts: 74
I did a quick search and found these services that will convert your image.
https://duckduckgo.com/?t=ffab&q=export ... cel&ia=web


Top
 Post subject: Re: Export image as excel
PostPosted: Mon Nov 04, 2024 5:06 pm  (#3) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
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")

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 2:09 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
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")


That is so kind of you but I'm sorry I have no idea where to put this code :(

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 3:55 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
AdmFubar wrote:
I did a quick search and found these services that will convert your image.
https://duckduckgo.com/?t=ffab&q=export ... cel&ia=web

Thank you...I have tried some of these and all I get is writing in the cells :(

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 9:31 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
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")

I have python console open....how do I import from PIL....Do I need to install anything? Do I need to install latest python release? I really need help please :)

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 10:51 am  (#7) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
The code won't run inside GIMP, as it needs pillow and openpyxl library to run
you'll need to run it using python (not GIMP's python console).
You can install python and install the libraries needed.
Or if you want I can email you the exe and you can just have your image.png (maximum current size is 50x50px) I just can't attach it on this forum because there's a limit of 6Mib file size.

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 10:57 am  (#8) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
oh try this (unzip it and you'll get the exe) just make sure your image.png file is in same folder as the exe and the run it (by double clicking I guess and it'll turn your image.png into an excel file.
http://www.mediafire.com/file/or67kehnl ... 2excel.zip

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 11:05 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
The code won't run inside GIMP, as it needs pillow and openpyxl library to run
you'll need to run it using python (not GIMP's python console).
You can install python and install the libraries needed.
Or if you want I can email you the exe and you can just have your image.png (maximum current size is 50x50px) I just can't attach it on this forum because there's a limit of 6Mib file size.

Ah ok I did wonder lol. I will send my email by DM to you if that's ok. Just tell me what do i do with the exe? Does this run inside gimp?

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 11:09 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
oh try this (unzip it and you'll get the exe) just make sure your image.png file is in same folder as the exe and the run it (by double clicking I guess and it'll turn your image.png into an excel file.
http://www.mediafire.com/file/or67kehnl ... 2excel.zip

Ok thank you. Is this a application on its own?

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Tue Nov 05, 2024 1:54 pm  (#11) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
yes, it is just the above code compiled as standalone exe.
Let me know if it worked for you.
When I tested it worked for me.

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Wed Nov 06, 2024 3:07 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
yes, it is just the above code compiled as standalone exe.
Let me know if it worked for you.
When I tested it worked for me.

Unfortunately does not install anything :(

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Wed Nov 06, 2024 3:38 pm  (#13) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
it doesn't install, if you unzip it there will be an exe file that you can double click on to run, it won't be under windows apps. you'll have to double click it while seeing it in file explorer.
www.youtube.com Video from : www.youtube.com

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Wed Nov 06, 2024 4:11 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
it doesn't install, if you unzip it there will be an exe file that you can double click on to run, it won't be under windows apps. you'll have to double click it while seeing it in file explorer.
www.youtube.com Video from : www.youtube.com

Yes I have exe file but when I click on it I get a black box for a second then nothing lol

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Wed Nov 06, 2024 4:35 pm  (#15) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
the black box means it's runny in command shell, it should have created excel file for you did you see my video, you have to name your image as image.png and it has to be 50x50 or smaller and in the same folder

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Wed Nov 06, 2024 4:51 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
the black box means it's runny in command shell, it should have created excel file for you did you see my video, you have to name your image as image.png and it has to be 50x50 or smaller and in the same folder

Ah yes did not put in the same folder....will try that. Thank you for all your help.

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Wed Nov 06, 2024 5:18 pm  (#17) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
you're welcome let me know when you're successful.

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Thu Nov 07, 2024 4:16 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
you're welcome let me know when you're successful.

Brilliant it worked :) How can I do this with bigger images as 50x50px is small?

_________________
Image


Top
 Post subject: Re: Export image as excel
PostPosted: Thu Nov 07, 2024 6:54 am  (#19) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 4554
Location: Canada
Try this one (it has maximum size of 2000x2000)
https://www.mediafire.com/file/or67kehn ... l.zip/file

_________________
Image
Visualize your and others dreams coming true.


Top
 Post subject: Re: Export image as excel
PostPosted: Thu Nov 07, 2024 7:53 am  (#20) 
Offline
GimpChat Member
User avatar

Joined: Dec 22, 2011
Posts: 399
trandoductin wrote:
Try this one (it has maximum size of 2000x2000)
https://www.mediafire.com/file/or67kehn ... l.zip/file

Wow this looks perfect....just downloaded it and a virus is detected? Do I need to worry?
Oh well hope not lol as I have used it and it works perfectly...thanks again :)

_________________
Image


Top
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group