diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index 9d4eaabb1..a08e932ab 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -534,7 +534,6 @@ RAWMODE = { "1": "L", "L": "L", "RGB": "RGB", - "RGBA": "RGB", "RGBX": "RGB", "CMYK": "CMYK;I", # assume adobe conventions "YCbCr": "YCbCr", diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 54f8b9fd1..692dc5279 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -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()