加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_format_lab.py 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
LLL 提交于 2022-06-27 15:20 . Import Upstream version 7.0.0
from PIL import Image
from .helper import PillowTestCase
class TestFormatLab(PillowTestCase):
def test_white(self):
with Image.open("Tests/images/lab.tif") as i:
i.load()
self.assertEqual(i.mode, "LAB")
self.assertEqual(i.getbands(), ("L", "A", "B"))
k = i.getpixel((0, 0))
L = i.getdata(0)
a = i.getdata(1)
b = i.getdata(2)
self.assertEqual(k, (255, 128, 128))
self.assertEqual(list(L), [255] * 100)
self.assertEqual(list(a), [128] * 100)
self.assertEqual(list(b), [128] * 100)
def test_green(self):
# l= 50 (/100), a = -100 (-128 .. 128) b=0 in PS
# == RGB: 0, 152, 117
with Image.open("Tests/images/lab-green.tif") as i:
k = i.getpixel((0, 0))
self.assertEqual(k, (128, 28, 128))
def test_red(self):
# l= 50 (/100), a = 100 (-128 .. 128) b=0 in PS
# == RGB: 255, 0, 124
with Image.open("Tests/images/lab-red.tif") as i:
k = i.getpixel((0, 0))
self.assertEqual(k, (128, 228, 128))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化