diff --git a/PIL/BmpImagePlugin.py b/PIL/BmpImagePlugin.py index 6f29fb767..b2a601cf1 100644 --- a/PIL/BmpImagePlugin.py +++ b/PIL/BmpImagePlugin.py @@ -85,8 +85,10 @@ class BmpImageFile(ImageFile.ImageFile): """ Read relevant info about the BMP """ read, seek = self.fp.read, self.fp.seek seek(2) + start_data = read(12) file_info = dict() - file_info['filesize'] = i32(read(12)[0:4]) # file size @offset 2 (offsets 4, 12 are reserved for OS/2 Icons) + file_info['filesize'] = i32(start_data[0:4]) # file size @offset 2 (offsets 4, 12 are reserved for OS/2 Icons) + file_info['image_offset'] = i32(start_data[8:12]) # file size @offset 2 (offsets 4, 12 are reserved for OS/2 Icons) file_info['header_size'] = i32(read(4)) # read bmp header size @offset 14 (this is part of the header size) file_info['direction'] = -1 header_data = ImageFile._safe_read(self.fp, file_info['header_size'] - 4) # read the rest of the bmp header, without its size @@ -101,7 +103,7 @@ class BmpImageFile(ImageFile.ImageFile): file_info['compression'] = self.RAW file_info['palette_padding'] = 3 #----------------------------------------------- Windows Bitmap v2 to v5 - elif file_info['header_size'] in {40, 64, 108, 124}: # v3, OS/2 v2, v4, v5 + elif file_info['header_size'] in (40, 64, 108, 124): # v3, OS/2 v2, v4, v5 if file_info['header_size'] >= 64: file_info['r_mask'] = i32(header_data[36:40]) file_info['g_mask'] = i32(header_data[40:44])