Typo "much".  "length" is not right.
Combine this with the previous test, then the error message can say what the input shape needs to be, and what it is.
Ideally, this function and its inverse would be written to accept shape (..., 3) instead of (M, N, 3).  One should be able to convert a single color triplet, or any array of them.