Call startswith/endswith once with a tuple

This commit is contained in:
Hugo van Kemenade 2025-03-03 23:56:43 +02:00
parent e4cac21044
commit a2b13cc02a
2 changed files with 2 additions and 3 deletions

View File

@ -123,8 +123,7 @@ def read_png_or_jpeg2000(
Image._decompression_bomb_check(im.size) Image._decompression_bomb_check(im.size)
return {"RGBA": im} return {"RGBA": im}
elif ( elif (
sig.startswith(b"\xff\x4f\xff\x51") sig.startswith((b"\xff\x4f\xff\x51", b"\x0d\x0a\x87\x0a"))
or sig.startswith(b"\x0d\x0a\x87\x0a")
or sig == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a" or sig == b"\x00\x00\x00\x0cjP \x0d\x0a\x87\x0a"
): ):
if not enable_jpeg2k: if not enable_jpeg2k:

View File

@ -1584,7 +1584,7 @@ class TiffImageFile(ImageFile.ImageFile):
# byte order. # byte order.
elif rawmode == "I;16": elif rawmode == "I;16":
rawmode = "I;16N" rawmode = "I;16N"
elif rawmode.endswith(";16B") or rawmode.endswith(";16L"): elif rawmode.endswith((";16B", ";16L")):
rawmode = rawmode[:-1] + "N" rawmode = rawmode[:-1] + "N"
# Offset in the tile tuple is 0, we go from 0,0 to # Offset in the tile tuple is 0, we go from 0,0 to