I have a question about the pixel values returned from an image opened with PIL load function. I am using the following code:
frame = Image.open(fname).load()
a = frame[10, 10]
If I load a GIF image, a
is the integer value 43. But if I convert the image a JPEG and rerun the code, a
is a tuple (253, 254, 100)
.
Why? And how can i convert (253, 254, 100)
back to 43?
GIFs are pallettized, whereas JPEGs are RGB. The act of transforming the image disposes of the palette, so you will have to look through the pallette entries in the GIF to find the closest match to the desired color.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With