diff --git a/PIL/Image.py b/PIL/Image.py index ed1d10907..c643e24d9 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1715,7 +1715,10 @@ class Image(object): if not format: if ext not in EXTENSION: init() - format = EXTENSION[ext] + try: + format = EXTENSION[ext] + except KeyError: + raise ValueError('unknown file extension: {}'.format(ext)) if format.upper() not in SAVE: init()