From 32a6c2268fd28c105e7d8cc9474ead637ee4283f Mon Sep 17 00:00:00 2001 From: jlwoolf Date: Wed, 21 Sep 2022 17:44:57 -0600 Subject: [PATCH] did not work with all .cur files --- src/PIL/BmpImagePlugin.py | 5 ++++- src/PIL/CurImagePlugin.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PIL/BmpImagePlugin.py b/src/PIL/BmpImagePlugin.py index 1041ab763..aba7d9e22 100644 --- a/src/PIL/BmpImagePlugin.py +++ b/src/PIL/BmpImagePlugin.py @@ -209,7 +209,10 @@ class BmpImageFile(ImageFile.ImageFile): else: raise OSError("Unsupported BMP bitfields layout") elif file_info["compression"] == self.RAW: - if file_info["bits"] == 32 and header == 22: # 32-bit .cur offset + try: self.is_cur + except: self.is_cur = False + + if file_info["bits"] == 32 and self.is_cur: raw_mode, self.mode = "BGRA", "RGBA" elif file_info["compression"] == self.RLE8: decoder_name = "bmp_rle" diff --git a/src/PIL/CurImagePlugin.py b/src/PIL/CurImagePlugin.py index 42af5cafc..e96e18d16 100644 --- a/src/PIL/CurImagePlugin.py +++ b/src/PIL/CurImagePlugin.py @@ -44,6 +44,7 @@ class CurImageFile(BmpImagePlugin.BmpImageFile): s = self.fp.read(6) if not _accept(s): raise SyntaxError("not a CUR file") + self.is_cur = True # pick the largest cursor in the file m = b""