Skip to content

Conversation

@radarhere
Copy link
Member

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.

@radarhere radarhere added the BMP label Dec 16, 2024
@hugovk hugovk merged commit 140e426 into python-pillow:main Mar 29, 2025
49 checks passed
@radarhere radarhere deleted the bmp branch March 29, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BmpImagePlugin - Unsupported 32bpp DIBs with Alpha

2 participants