Page 1 of 1

Getting RGB values out of image

Posted: Sat Dec 04, 2021 4:00 pm
by okdude
Hey there! Is there any option on getting RGB values out of an image? I could not find anything. Is this possible in pure python?

Re: Getting RGB values out of image

Posted: Sun Dec 05, 2021 11:07 am
by pythoncoder
You'll have to give us more information if we are to help. Please describe the image format.

Re: Getting RGB values out of image

Posted: Sun Dec 05, 2021 6:22 pm
by okdude
It’s 8x8 PNG. I need to get the RGB value of every pixel in the image.

Re: Getting RGB values out of image

Posted: Sun Dec 05, 2021 6:47 pm
by pythoncoder
PNG format is quite involved. For a file that small it might be worth using a format conversion tool to copy it to a simpler format such as uncompressed BMP. Getting pixel data from that should be fairly easy.

Re: Getting RGB values out of image

Posted: Sun Dec 05, 2021 10:43 pm
by okdude
Thank you! I will look into this tomorrow.

Re: Getting RGB values out of image

Posted: Mon Dec 06, 2021 10:17 am
by okdude
pythoncoder wrote:
Sun Dec 05, 2021 6:47 pm
PNG format is quite involved. For a file that small it might be worth using a format conversion tool to copy it to a simpler format such as uncompressed BMP. Getting pixel data from that should be fairly easy.
Any tips on how to convert this? I can only find solutions that involve using Pillow :/

Re: Getting RGB values out of image

Posted: Mon Dec 06, 2021 10:25 am
by pythoncoder
As usual there are two options. Search for a library someone's already written; failing that, look up the spec for a BMP file and do it yourself.

This isn't something I've investigated in detail, but I do know that uncompressed BMP is one of the simplest graphics formats.