From 096c479cfb2f71fecbb38a9b2dc12e5a49518ed8 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 19 Jan 2026 11:28:42 +0200 Subject: [PATCH] If plugin has already been imported and registered the extension, return early Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com> --- src/PIL/Image.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index cd1abb935..dfd64ef19 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -406,6 +406,9 @@ def _load_plugin_for_extension(ext: str | bytes) -> bool: """Load only the plugin needed for a specific file extension.""" if isinstance(ext, bytes): ext = ext.decode() + if ext in EXTENSION: + return True + plugin = _EXTENSION_PLUGIN.get(ext.lower()) if plugin is None: return False