[英]Wand python get pixel color with 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
问题:
from wand.image import Image
with Image(blob=img, format='GIF') as picture:
print picture[1][1].string
# return srgb(93%,93%,93%) why?
这就是颜色合规性的工作原理。 并非所讨论像素的所有部分都可以表示为 8 位无符号整数,因此它表示为标准化百分比 - 介于0%
和100%
。
尝试以下...
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)
这是我的 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.