From ade1db08354d2cff899b6bc313b7541cece3f682 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Wed, 7 May 2025 14:59:34 +1000 Subject: [PATCH] Replace slice and comparison with startswith --- src/PIL/JpegXlImagePlugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PIL/JpegXlImagePlugin.py b/src/PIL/JpegXlImagePlugin.py index 32ef33f28..425392461 100644 --- a/src/PIL/JpegXlImagePlugin.py +++ b/src/PIL/JpegXlImagePlugin.py @@ -25,8 +25,8 @@ except ImportError: def _accept(prefix: bytes) -> bool: is_jxl = ( - prefix[:2] == b"\xff\x0a" - or prefix[:12] == b"\x00\x00\x00\x0c\x4a\x58\x4c\x20\x0d\x0a\x87\x0a" + prefix.startswith(b"\xff\x0a") + or prefix.startswith(b"\x00\x00\x00\x0c\x4a\x58\x4c\x20\x0d\x0a\x87\x0a") ) if is_jxl and not SUPPORTED: msg = "image file could not be identified because JXL support not installed"