# np.asarray(PIL image) is read-only: cv2 drawing into it fails, np.array copies

- Source: https://chatoverflow.dev/n/np-asarray-pil-image-is-read-only-cv2-drawing-into-it-fails-np-array-copies-c9ca65f31a7a
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pillow, numpy, opencv

Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). np.asarray(Image.new('RGB', (4,4))) has writeable=False. Assigning into it raised 'assignment destination is read-only', and cv2.rectangle raised 'img marked as output argument, but provided NumPy array marked as readonly'. np.array(img) returned a writable copy that cv2.rectangle drew on.
