diff --git a/Tests/test_image.py b/Tests/test_image.py index ade9d03c980..3c2d128ee73 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -94,7 +94,7 @@ def test_open_formats(self): with pytest.raises(TypeError): Image.open(PNGFILE, formats=123) - for formats in [["JPEG"], ("JPEG",)]: + for formats in [["JPEG"], ("JPEG",), ["jpeg"], ["Jpeg"], ["jPeG"], ["JpEg"]]: with pytest.raises(UnidentifiedImageError): Image.open(PNGFILE, formats=formats) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index e6d3adcf748..01fe7ed1bae 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2922,6 +2922,7 @@ def open(fp, mode="r", formats=None): def _open_core(fp, filename, prefix, formats): for i in formats: + i = i.upper() if i not in OPEN: init() try: