From d19fa7107d3220d420964820368b2438bb4385da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B1=B4=ED=9D=AC?= Date: Thu, 27 Oct 2022 09:44:22 +0900 Subject: [PATCH] MODIFY Image.py save() -> ADD convert JPG->JPEG code --- src/PIL/Image.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 7faf0c248..f44e4415a 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -97,7 +97,7 @@ try: # import Image and use the Image.core variable instead. # Also note that Image.core is not a publicly documented interface, # and should be considered private and subject to change. - from . import _imaging as core + from .. import _imaging as core if __version__ != getattr(core, "PILLOW_VERSION", None): raise ImportError( @@ -225,6 +225,10 @@ OPEN = {} MIME = {} SAVE = {} SAVE_ALL = {} +# Convert jpg to jpeg, Can apply other case. +FORMAT_MAP = { + 'JPG': 'jpeg', +} EXTENSION = {} DECODERS = {} ENCODERS = {} @@ -2332,6 +2336,7 @@ class Image: except KeyError as e: raise ValueError(f"unknown file extension: {ext}") from e + format = FORMAT_MAP.get(format.upper(), format) if format.upper() not in SAVE: init() if save_all: