What did you do?
Loading a BMP file with BGRX palette format causes the ImagePalette.color property to misinterpret it as RGB and return garbage.
What did you expect to happen?
ImagePalette.color should contain properly decoded RGB colors despite the underlying rawmode being BGRX.
What actually happened?
ImagePalette.color contains garbage.
What are your OS, Python and Pillow versions?
- OS: Linux
- Python: 3.14
- Pillow: 12.3.0
$ python3 -m PIL.report
--------------------------------------------------------------------
Pillow 12.3.0
Python 3.14.3 (main, Mar 29 2026, 21:45:15) [GCC 15.2.0]
--------------------------------------------------------------------
Python executable is [REDACTED venv path]/bin/python3
Environment Python files loaded from [REDACTED venv path]
System Python files loaded from [REDACTED Python installation path]
--------------------------------------------------------------------
Python Pillow modules loaded from [REDACTED venv path]/lib/python3.14/site-packages/PIL
Binary Pillow modules loaded from [REDACTED venv path]/lib/python3.14/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 12.3.0
*** TKINTER support not installed
--- FREETYPE2 support ok, loaded 2.14.3
--- LITTLECMS2 support ok, loaded 2.19
--- WEBP support ok, loaded 1.6.0
--- AVIF support ok, loaded 1.4.2
--- JPEG support ok, compiled for libjpeg-turbo 3.1.4.1
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.4
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1, compiled for zlib-ng 2.3.3
--- LIBTIFF support ok, loaded 4.7.1
--- RAQM (Bidirectional Text) support ok, loaded 0.10.5, fribidi 1.0.16, harfbuzz 14.2.1
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
>>> from PIL import Image
>>> from io import BytesIO
>>> img = Image.open(BytesIO(bytes.fromhex('''
... 424d4e000000000000004a00000028000000010000000100000001000400
... 0000000004000000232e0000232e0000050000000500000000000000ffff
... ff000000ff0000ff0000ff00000010000000
... ''')))
>>> img.palette.rawmode
'BGRX'
>>> img.palette.mode
'RGB'
>>> img.palette.colors == {(0, 0, 0): 0, (255, 255, 255): 1, (255, 0, 0): 2, (0, 255, 0): 3, (0, 0, 255): 4}
False
>>> img.palette.colors
{(0, 0, 0): 0, (0, 255, 255): 1, (255, 0, 0): 2, (0, 255, 0): 3, (0, 0): 6}
What did you do?
Loading a BMP file with BGRX palette format causes the
ImagePalette.colorproperty to misinterpret it as RGB and return garbage.What did you expect to happen?
ImagePalette.colorshould contain properly decoded RGB colors despite the underlying rawmode beingBGRX.What actually happened?
ImagePalette.colorcontains garbage.What are your OS, Python and Pillow versions?