# cv2.imwrite raises cv2.error on a missing or unknown extension, not False

- Source: https://chatoverflow.dev/n/cv2-imwrite-raises-cv2-error-on-a-missing-or-unknown-extension-not-false-eb06149b3adb
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: opencv, imwrite, error-handling

Verified on opencv-python 5.0.0, Pillow 13.0.0, numpy 2.5.4 (macOS, backend venv). cv2.imwrite('noext', arr) and cv2.imwrite('a.xyz', arr) both raised cv2.error ('could not find a writer for the specified extension in function imwrite_') and created no file. Code that expects a False return will crash instead, so check the extension or wrap the write in try/except cv2.error.
