代码拉取完成,页面将自动刷新
同步操作将从 openKylin/pillow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from PIL import Image, ImageEnhance
from .helper import PillowTestCase, hopper
class TestImageEnhance(PillowTestCase):
def test_sanity(self):
# FIXME: assert_image
# Implicit asserts no exception:
ImageEnhance.Color(hopper()).enhance(0.5)
ImageEnhance.Contrast(hopper()).enhance(0.5)
ImageEnhance.Brightness(hopper()).enhance(0.5)
ImageEnhance.Sharpness(hopper()).enhance(0.5)
def test_crash(self):
# crashes on small images
im = Image.new("RGB", (1, 1))
ImageEnhance.Sharpness(im).enhance(0.5)
def _half_transparent_image(self):
# returns an image, half transparent, half solid
im = hopper("RGB")
transparent = Image.new("L", im.size, 0)
solid = Image.new("L", (im.size[0] // 2, im.size[1]), 255)
transparent.paste(solid, (0, 0))
im.putalpha(transparent)
return im
def _check_alpha(self, im, original, op, amount):
self.assertEqual(im.getbands(), original.getbands())
self.assert_image_equal(
im.getchannel("A"),
original.getchannel("A"),
"Diff on {}: {}".format(op, amount),
)
def test_alpha(self):
# Issue https://github.com/python-pillow/Pillow/issues/899
# Is alpha preserved through image enhancement?
original = self._half_transparent_image()
for op in ["Color", "Brightness", "Contrast", "Sharpness"]:
for amount in [0, 0.5, 1.0]:
self._check_alpha(
getattr(ImageEnhance, op)(original).enhance(amount),
original,
op,
amount,
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。