在Python3.7中,我使用OpenCV读取PNG图像,并将其转换为jpg图像流.如何确定流的字节数?
image=cv2.imread('test.png',0)
image_stream = io.BytesIO(cv2.imencode(".jpg",image)[1].tobytes())
在Python3.7中,我使用OpenCV读取PNG图像,并将其转换为jpg图像流.如何确定流的字节数?
image=cv2.imread('test.png',0)
image_stream = io.BytesIO(cv2.imencode(".jpg",image)[1].tobytes())
(success, data) = cv2.imencode(".jpg", image)
assert success
print(data.nbytes)
此字节数与.tobytes()
调用返回的bytes
对象的大小相同.创建BytesIO()
也不会影响此大小.