mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	Merge pull request #5606 from radarhere/convert_transparency
This commit is contained in:
		
						commit
						3d35e5458f
					
				|  | @ -104,18 +104,22 @@ def test_trns_p(tmp_path): | ||||||
| # ref https://github.com/python-pillow/Pillow/issues/664 | # ref https://github.com/python-pillow/Pillow/issues/664 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_trns_p_rgba(): | @pytest.mark.parametrize("mode", ("LA", "PA", "RGBA")) | ||||||
|  | def test_trns_p_transparency(mode): | ||||||
|     # Arrange |     # Arrange | ||||||
|     im = hopper("P") |     im = hopper("P") | ||||||
|     im.info["transparency"] = 128 |     im.info["transparency"] = 128 | ||||||
| 
 | 
 | ||||||
|     # Act |     # Act | ||||||
|     im_rgba = im.convert("RGBA") |     converted_im = im.convert(mode) | ||||||
| 
 | 
 | ||||||
|     # Assert |     # Assert | ||||||
|     assert "transparency" not in im_rgba.info |     assert "transparency" not in converted_im.info | ||||||
|     # https://github.com/python-pillow/Pillow/issues/2702 |     if mode == "PA": | ||||||
|     assert im_rgba.palette is None |         assert converted_im.palette is not None | ||||||
|  |     else: | ||||||
|  |         # https://github.com/python-pillow/Pillow/issues/2702 | ||||||
|  |         assert converted_im.palette is None | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_trns_l(tmp_path): | def test_trns_l(tmp_path): | ||||||
|  |  | ||||||
|  | @ -1007,7 +1007,7 @@ class Image: | ||||||
|                             trns_im = trns_im.convert("RGB") |                             trns_im = trns_im.convert("RGB") | ||||||
|                         trns = trns_im.getpixel((0, 0)) |                         trns = trns_im.getpixel((0, 0)) | ||||||
| 
 | 
 | ||||||
|             elif self.mode == "P" and mode == "RGBA": |             elif self.mode == "P" and mode in ("LA", "PA", "RGBA"): | ||||||
|                 t = self.info["transparency"] |                 t = self.info["transparency"] | ||||||
|                 delete_trns = True |                 delete_trns = True | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user