OpenCV:如果从缓冲区读取,如何获取图像格式?(OpenCV: how to get image format if reading from buffer?)
我从缓冲区读取图像(格式未知,最常见的是PNG或JPG)。 我可以使用
cv2.imdecode
解码它,我甚至可以检查它是否有效(imdecode
返回非None)。但是,如何才能揭示我刚读过的缓冲区的图像类型 (PNG,JPG,还有其他内容)?
I read an image (of unknown format, most frequent are PNGs or JPGs) from a buffer. I can decode it with
cv2.imdecode
, I can even check if it is valid (imdecode
returns non-None).But how can I reveal the image type (PNG, JPG, something else) of the buffer I've just read?
原文:https://stackoverflow.com/questions/27608053
更新时间:2023-07-14 14:07