开发者

Python PIL: color index to RGB

开发者 https://www.devze.com 2022-12-22 03:11 出处:网络
following this link i was able to load and read pixels from a .gif. That question specifically askes for a RGB value, but the accepted (and most voted answer) that I used as reference gets me to get a

following this link i was able to load and read pixels from a .gif. That question specifically askes for a RGB value, but the accepted (and most voted answer) that I used as reference gets me to get an int as value开发者_如何学JAVA. What is it? I guess some sort of index, but how to convert it to a proper rgb value? Thanks

[..]
img = Image.open(GIF_FILENAME)
pix = img.load()
for i in range(5):
    print img.getpixel((i, 0))
    # this returns me like 78, 65.. how to get RGB?
[..]


img = Image.open(GIF_FILENAME)
rgbimg = img.convert('RGB')
for i in range(5):
    print rgbimg.getpixel((i, 0))
0

精彩评论

暂无评论...
验证码 换一张
取 消