Image bytes to np array in Python
For reference:
# data - image bytes
im = Image.open(BytesIO(data))
I = numpy.asarray(im)
print("I type:", type(I), "I shape:", I.shape)
>> I type: <class 'numpy.ndarray'> I shape: (512, 512, 3)
# data - image bytes
im = Image.open(BytesIO(data))
I = numpy.asarray(im)
print("I type:", type(I), "I shape:", I.shape)
>> I type: <class 'numpy.ndarray'> I shape: (512, 512, 3)
Comments
Post a Comment