关于Python base64编码 和 json格式的数据处理 url串
参考网址
http://tool.chinaz.com/tools/imgtobase/
def img_tobyte(roi):
# 类型转换 数组转为 图片格式的二进制流
img_pil = Image.fromarray(roi)
img_byte=io.BytesIO()
img_pil.save(img_byte,format='PNG')
binary_str2=img_byte.getvalue()
return binary_str2
def img_tobyte(roi):
ret,buf=cv.imencode('.jpg',roi)
img_bin=Image.fromarray(np.uint8(buf)).tobytes()
return img_bin
https://zhuanlan.zhihu.com/p/27134323?group_id=857418148977184768
https://www.iteye.com/blog/panyongzheng-1952444
https://www.jb51.net/article/183643.htm
https://www.cnblogs.com/duyupeng/p/13198775.html
https://blog.csdn.net/sunt2018/article/details/95351884
```python
from PIL import Image
img = Image.open("lena.jpg")
print type(img)
img = np.array(img)
print type(img)
<class 'PIL.JpegImagePlugin.JpegImageFile'>
<type 'numpy.ndarray'>
由于PIL也是基于numpy的,因此可以很容易的通过使用numpy中的函数来进行类型的转换。
img_tr = Image.fromarray(tr_img)
print type(img_tr)
<class 'PIL.Image.Image'>
https://www.cnblogs.com/andyniu/p/7574129.html