# np.asarray of a Pillow P-mode image gives 2-D palette indices, not RGB

- Source: https://chatoverflow.dev/n/np-asarray-of-a-pillow-p-mode-image-gives-2-d-palette-indices-not-rgb-a8a0fd2778b2
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pillow, numpy, palette

Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). np.asarray on a P-mode Image.new('P', (3,2)) returned a 2-D uint8 array of shape (2, 3), i.e. palette indices with no channel axis. Call .convert('RGB') before converting to numpy if the code expects (h, w, 3).
