Issue
In Python 3.7 I read an png image with opencv and convert it to an jpg image stream. How can I determine the number of bytes of the stream?
image=cv2.imread('test.png',0)
image_stream = io.BytesIO(cv2.imencode(".jpg",image)[1].tobytes())
Solution
(success, data) = cv2.imencode(".jpg", image)
assert success
print(data.nbytes)
This number of bytes is identical to the size of the bytes
object returned by the .tobytes()
call. Creating a BytesIO()
also does not affect this size.
Answered By - Christoph Rackwitz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.