mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-05 22:20:54 +03:00
Merge pull request #3182 from danpla/png-fix-trns-test
TestFilePng: Fix test_save_l_transparency()
This commit is contained in:
commit
1b3c3da3eb
|
@ -292,15 +292,29 @@ class TestFilePng(PillowTestCase):
|
||||||
self.assertEqual(im.getcolors(), [(100, (0, 0, 0, 0))])
|
self.assertEqual(im.getcolors(), [(100, (0, 0, 0, 0))])
|
||||||
|
|
||||||
def test_save_l_transparency(self):
|
def test_save_l_transparency(self):
|
||||||
|
# There are 559 transparent pixels in l_trns.png.
|
||||||
|
num_transparent = 559
|
||||||
|
|
||||||
in_file = "Tests/images/l_trns.png"
|
in_file = "Tests/images/l_trns.png"
|
||||||
im = Image.open(in_file)
|
im = Image.open(in_file)
|
||||||
|
self.assertEqual(im.mode, "L")
|
||||||
|
self.assertEqual(im.info["transparency"], 255)
|
||||||
|
|
||||||
|
im_rgba = im.convert('RGBA')
|
||||||
|
self.assertEqual(
|
||||||
|
im_rgba.getchannel("A").getcolors()[0][0], num_transparent)
|
||||||
|
|
||||||
test_file = self.tempfile("temp.png")
|
test_file = self.tempfile("temp.png")
|
||||||
im.save(test_file)
|
im.save(test_file)
|
||||||
|
|
||||||
# There are 559 transparent pixels.
|
test_im = Image.open(test_file)
|
||||||
im = im.convert('RGBA')
|
self.assertEqual(test_im.mode, "L")
|
||||||
self.assertEqual(im.getchannel('A').getcolors()[0][0], 559)
|
self.assertEqual(test_im.info["transparency"], 255)
|
||||||
|
self.assert_image_equal(im, test_im)
|
||||||
|
|
||||||
|
test_im_rgba = test_im.convert('RGBA')
|
||||||
|
self.assertEqual(
|
||||||
|
test_im_rgba.getchannel('A').getcolors()[0][0], num_transparent)
|
||||||
|
|
||||||
def test_save_rgb_single_transparency(self):
|
def test_save_rgb_single_transparency(self):
|
||||||
in_file = "Tests/images/caption_6_33_22.png"
|
in_file = "Tests/images/caption_6_33_22.png"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user