简体   繁体   English

Wand python 使用 GIF 获取像素颜色

[英]Wand python get pixel color with GIF

I want get rgb color some pixel in gif我想在 gif 中获得一些像素的 rgb 颜色

from wand.image import Image
with Image(blob=img, format='JPG') as picture:
    print picture[1][1].string 
    # return srgb(0,0,0) is good

Problem:问题:

from wand.image import Image
with Image(blob=img, format='GIF') as picture:
    print picture[1][1].string 
    # return srgb(93%,93%,93%) why?

This is how color compliance works.这就是颜色合规性的工作原理。 Not all parts of the pixel in question can be represented as a 8-bit unsigned integer, so it's represented as a normalized percent -- between 0% and 100% .并非所讨论像素的所有部分都可以表示为 8 位无符号整数,因此它表示为标准化百分比 - 介于0%100%

Try the following...尝试以下...

from wand.image import Image
with Image(blob=img, format='GIF') as picture:
    picture.depth = 8
    print picture[1, 1].string
    #=> srgb(274,274,274)

This is my code for png (python3)这是我的 png (python3) 代码

from wand.image import Image

with Image(filename='white_background_320x200_edited_alphaoff.png') as img:
    print(img[1][1])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM