format overrides file extension when saving

This commit is contained in:
Andrew Murray 2026-01-22 00:28:26 +11:00
parent a0f51493ca
commit a6b36f0b6b

View File

@ -2631,14 +2631,20 @@ class Image:
# only set the name for metadata purposes
filename = os.fspath(fp.name)
filename_ext = os.path.splitext(filename)[1].lower()
ext = filename_ext.decode() if isinstance(filename_ext, bytes) else filename_ext
# Try importing only the plugin for this extension first
if not _import_plugin_for_extension(ext):
if format:
preinit()
else:
filename_ext = os.path.splitext(filename)[1].lower()
ext = (
filename_ext.decode()
if isinstance(filename_ext, bytes)
else filename_ext
)
# Try importing only the plugin for this extension first
if not _import_plugin_for_extension(ext):
preinit()
if not format:
if ext not in EXTENSION:
init()
try: