mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +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",
|
"1": "L",
|
||||||
"L": "L",
|
"L": "L",
|
||||||
"RGB": "RGB",
|
"RGB": "RGB",
|
||||||
"RGBA": "RGB",
|
|
||||||
"RGBX": "RGB",
|
"RGBX": "RGB",
|
||||||
"CMYK": "CMYK;I", # assume adobe conventions
|
"CMYK": "CMYK;I", # assume adobe conventions
|
||||||
"YCbCr": "YCbCr",
|
"YCbCr": "YCbCr",
|
||||||
|
|
|
@ -450,6 +450,19 @@ class TestFileJpeg(PillowTestCase):
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(im.format, "JPEG")
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user