二进制字符串转png图像

如本文章标有价格,需议价或其它事情商议请加微信pythonxia

"""
字符串转换为图片,图片转换成字符串,二进制数据转换成内存中的图片
"""

import base64
from io import BytesIO

picstring = b'iVBORw0KGgoAAAANSUhEUgAAAFUAAABGCAYAAAC9t9hvAAAEVUlEQVR4nO2aS24iMRCGy9GojwK5xKwyV4gihU2kSKxyiblGVmxgFOUKM6tcApibsPEsghnj9qPKLpfdkF9CUZrG7f74XQ83Cq5A89eD9h3fLQdV43pVBu1JIaC2uOHecA42VWHAU3TRTvXB2r29j897uP//PoNrr8qpPqCx47n6xjrahGXAzl8PutSt2VDdpVUrk0pr9/ZeDBYFNRbIT0vnbh0O9n8WTYDvloPiTkIYRaEG6ztqDHKBN4KMValbvR/CZs1iCcAdhSnKfWTOb+TUoklQZRzcq3Pv1jpnbmcllShQW7F4PEGdoDYDanS31jXgFlclGXO6AeBv04pU2bV291RLN2JJiSJmsNI19FW1qUa13eqFKrFEkipw6/z1oO0XgKxbr6L3l84ZweXfhVsrqub9RWPq/OG+LdyJ1q8KgLY8xCuDzG6Lte4mzuF0cm7cEYHMALYJVHcStZR1cwV7AyxgS6CGJsMlSbfYKgZLvHawpLLrOg7A0rGYzRQZXyb5AzmTZQFKuLnUHNHzyVwdVboMtgThCnmTqcw/f7hPz6sg3LD3/j3seNmhywevJlAAZqglQFFNRkYz0KJ5Yev9qUDdm+VOZNlPUhke7bDE1NIlTwaakbRQ12B6VtZ8PzXLoYkw4G77AciGAfGtv9o/cMju+Rmf6Io4dbcclHmxlVsBt2ZtRjM/ImdxarPfUQWey1NXgx4Ada464HKQaEx1bzQW5yRioP5YgP5Y4M8fQGO+AFGHVdu3tdyKeTrsA6m+r0fHYsBjrr2MZ1THMJBKUi4kH0jf+/pjAbA6f08DaPXoB3sZUAFGicsGmoKpfz+OhlM/NqCfj5979l9Sbz5DgQu3qx+GkQr10BjHWGzGwLjTBxUAAH7h8dhgmxf/RlyFuqlEsEnIBXo7m8HtbJZ9fYCOnIpNYlgXh4CmnGqAbn/+RV3nbOyjW7txKkaUsBBKQin3bvd72O73pHm5Yk9Ubh2HLZhr6Cx7x86zk1KB9OazImCDGiqKzfEU3FBXVmOfwEA+QWcAakts+WO7kRqKhQJKR4WR3oAWj6klcKfy+y625a8OoCiwsGHBlQt2+zIkO6MSuYW9KfhjYnVqTlJKOXf7MgSPh94bXSOVqALtZujc1Pmsmbk0ZpovJXcc6qaIfU0AvwtDAGOOZYHaKgFxyF1dHGCLl/+UgfrkAxiCd/m7VBkK5QBKjPWp2KnqAKpl19Ravi+AtaQCmE44OM3XWdqlLgVghDoVmEaYehMr9QjK3rC+zpi6Ov+Xw522uoEqFj5W40PcIaB6gkE90vUkuhpwQ3HUe24B2KpQc4FSPu/V6vj3aXwdGyj3sj+NW2NQoxgUShmGgrsKHH/yt6K1gAI0gpq78YI6ceW5HkOXRJEoVK4mIce5BlYqnnYPtQdR69EvqEhJuPNsPM7BehXFrRyAJ/XcX0Ic7esXVI9KwXbTptYStgVl3WDhGqhXSXRQrv4BmLpo1UgpUgUAAAAASUVORK5CYII='

imagedata = base64.b64decode(picstring)

#将二进制字符串(图片)decode为图片

 

如需要查看完整代码,请扫码付款:

VIP免费查看

已有0人支付

本站所有作品,教程等皆为原创,版权所有。只供个人及单位内部研究使用,对外展示或传播必需经本站同意,且注明来自本站。培训机构等用本站资源培训学生,需经本站授权。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。亦可直接向微信号scratch8付款购买。入住QQ群:225792826 和爱好者共同交流,并且能下载免费提供的Python资源(需提供真实姓名才可入群)
李兴球的博客_Python创意编程技术前沿_pygame » 二进制字符串转png图像
scratch

学本领,探索更大的世界!

李兴球博客 风火轮编程主页