mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
do not allow to save images discarding alpha channel
This commit is contained in:
parent
4f4c982229
commit
c1da18e0ad
|
@ -534,7 +534,6 @@ RAWMODE = {
|
|||
"1": "L",
|
||||
"L": "L",
|
||||
"RGB": "RGB",
|
||||
"RGBA": "RGB",
|
||||
"RGBX": "RGB",
|
||||
"CMYK": "CMYK;I", # assume adobe conventions
|
||||
"YCbCr": "YCbCr",
|
||||
|
|
|
@ -450,6 +450,19 @@ class TestFileJpeg(PillowTestCase):
|
|||
# Assert
|
||||
self.assertEqual(im.format, "JPEG")
|
||||
|
||||
def test_save_correct_modes(self):
|
||||
out = BytesIO()
|
||||
for mode in ['1', 'L', 'RGB', 'RGBX', 'CMYK', 'YCbCr']:
|
||||
img = Image.new(mode, (20, 20))
|
||||
img.save(out, "JPEG")
|
||||
|
||||
def test_save_wrong_modes(self):
|
||||
# ref https://github.com/python-pillow/Pillow/issues/2005
|
||||
out = BytesIO()
|
||||
for mode in ['LA', 'La', 'RGBA', 'RGBa', 'P']:
|
||||
img = Image.new(mode, (20, 20))
|
||||
self.assertRaises(IOError, img.save, out, "JPEG")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user