diff --git a/PIL/BmpImagePlugin.py b/PIL/BmpImagePlugin.py index 950ee13a1..eccd29923 100644 --- a/PIL/BmpImagePlugin.py +++ b/PIL/BmpImagePlugin.py @@ -112,7 +112,9 @@ class BmpImageFile(ImageFile.ImageFile): # 40 byte headers only have the three components in the bitfields masks, # ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx # See also https://github.com/python-pillow/Pillow/issues/1293 - file_info['a_mask'] = 0xff000000 + # There is a 4th component in the RGBQuad, in the alpha location, but it + # is listed as a reserved component, and it is not generally an alpha channel + file_info['a_mask'] = 0x0 for mask in ['r_mask', 'g_mask', 'b_mask']: file_info[mask] = i32(read(4)) file_info['rgb_mask'] = (file_info['r_mask'], file_info['g_mask'], file_info['b_mask']) diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py index 29d59ee44..1e373d037 100644 --- a/Tests/test_file_bmp.py +++ b/Tests/test_file_bmp.py @@ -74,8 +74,9 @@ class TestFileBmp(PillowTestCase): # test for #1293, Imagegrab returning Unsupported Bitfields Format im = BmpImagePlugin.DibImageFile('Tests/images/clipboard.dib') target = Image.open('Tests/images/clipboard_target.png') + # test only the RGB components, as there is no alpha in the DIB file. self.assert_image_equal(im.convert('RGB'), target.convert('RGB')) - self.assert_image_similar(im, target, 1) + if __name__ == '__main__':