Added USE_RAW_ALPHA for BMP images by radarhere · Pull Request #8602 · python-pillow/Pillow
Resolves #8594
https://learn.microsoft.com/en-us/windows/win32/wmdm/-bitmapinfoheader describes 32 bitcount as
The bitmap has a maximum of 2^32 colors. If the biCompression member is BI_RGB, the bmiColors member is NULL. Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each DWORD is not used.
where BI_RGB is what we call RAW compression. It is saying that the fourth channel is unused, as Pillow currently treats it as such for DIB images.
However, the issue has found that some images do not follow the documentation and store alpha data in the fourth channel anyway.
Because this is not the documented behaviour, it seems possible that using it anyway could introduce problems. If the user thinks that their images are in this form though, then I've added a USE_RAW_ALPHA setting that can be enabled.