mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
F mode support
This commit is contained in:
parent
d970a39840
commit
a576b14056
|
@ -46,16 +46,21 @@ class TestImageReduce(PillowTestCase):
|
||||||
im.reduce(3)
|
im.reduce(3)
|
||||||
|
|
||||||
def get_image(self, mode):
|
def get_image(self, mode):
|
||||||
bands = [self.gradients_image]
|
mode_info = ImageMode.getmode(mode)
|
||||||
for _ in ImageMode.getmode(mode).bands[1:]:
|
if mode_info.basetype == 'L':
|
||||||
# rotate previous image
|
bands = [self.gradients_image]
|
||||||
band = bands[-1].transpose(Image.ROTATE_90)
|
for _ in mode_info.bands[1:]:
|
||||||
bands.append(band)
|
# rotate previous image
|
||||||
# Correct alpha channel to exclude completely transparent pixels.
|
band = bands[-1].transpose(Image.ROTATE_90)
|
||||||
# Low alpha values also emphasize error after alpha multiplication.
|
bands.append(band)
|
||||||
if mode.endswith('A'):
|
# Correct alpha channel to exclude completely transparent pixels.
|
||||||
bands[-1] = bands[-1].point(lambda x: int(85 + x / 1.5))
|
# Low alpha values also emphasize error after alpha multiplication.
|
||||||
return Image.merge(mode, bands)
|
if mode.endswith('A'):
|
||||||
|
bands[-1] = bands[-1].point(lambda x: int(85 + x / 1.5))
|
||||||
|
return Image.merge(mode, bands)
|
||||||
|
else:
|
||||||
|
assert len(mode_info.bands) == 1
|
||||||
|
return self.gradients_image.convert(mode)
|
||||||
|
|
||||||
def compare_reduce_with_reference(self, im, factor, average_diff=0.4, max_diff=1):
|
def compare_reduce_with_reference(self, im, factor, average_diff=0.4, max_diff=1):
|
||||||
"""Image.reduce() should look very similar to Image.resize(BOX).
|
"""Image.reduce() should look very similar to Image.resize(BOX).
|
||||||
|
@ -172,7 +177,7 @@ class TestImageReduce(PillowTestCase):
|
||||||
for factor in self.remarkable_factors:
|
for factor in self.remarkable_factors:
|
||||||
self.compare_reduce_with_reference(im, factor)
|
self.compare_reduce_with_reference(im, factor)
|
||||||
|
|
||||||
def test_mode_CMYK(self):
|
def test_mode_F(self):
|
||||||
im = self.get_image("CMYK")
|
im = self.get_image("F")
|
||||||
for factor in self.remarkable_factors:
|
for factor in self.remarkable_factors:
|
||||||
self.compare_reduce_with_reference(im, factor)
|
self.compare_reduce_with_reference(im, factor)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user