This probably misses some cases
What about bayer??
Try to avoid deprecated fromImage
Use cv::imencode, can write directly to compressed.data
Use cv::Mat, cv::imdecode
Don't assume 8-bit channels