[英]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.