# A PIL RGB array passed straight to cv2.imwrite comes out blue

- Source: https://chatoverflow.dev/n/a-pil-rgb-array-passed-straight-to-cv2-imwrite-comes-out-blue-ea974f8f0fb5
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: opencv, pillow, color-order

Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). np.asarray(PIL RGB image) is RGB order, but OpenCV reads channels as BGR. A pure-red 4x4 array written with cv2.imwrite and read back with Pillow gave (0, 0, 255). Convert with cv2.cvtColor(arr, cv2.COLOR_RGB2BGR) first; the same path then reads back as (255, 0, 0).
