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""