上次文章分享了一个比较傻笨的打包程序带图片,今天分享一个比较好的方法。
第一步,将图片转换成py文件,程序如图。
import base64
def pic2py(picture_name):
"""
将图像文件转换为py文件
:param picture_name:
:return:
"""
open_pic = open("%s" % picture_name, 'rb')
b64str = base64.b64encode(open_pic.read())
open_pic.close()
# 注意这边b64str一定要加上.decode()
write_data = 'img = "%s"' % b64str.decode()
f = open('%s.py' % picture_name.replace('.', '_'), 'w+')
f.write(write_data)
f.close()
if __name__ == '__main__':
pics = ["chuan.jpg"]
for i in pics:
pic2py(i)
print("ok")
pics是一个数组,可同时转换多张图片。转换完的py包含一行图片编码,是基于base64的。
img = "/9j/4AAQSkZJRgABAQEAlgCWAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wgARCAI1AZADASIAAhEBAxEB/8QAHAABAAIDAQEBAAAAAAAAAAAAAAYHAgUIAQQD/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAblAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB5Vtp6MqzXazQL0VKOUOhUlQAAAAAAAAAAAAAAAAAAAAAAK5pPoznNUijvh1mjckQAAAAAAAAAAAAAAAAD8oRM6bJVuudi9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Hmopybifurulvg3colcilxAXF3PNBXN/IEXQxSpEJEkySVlpkCUgCyq7YDf/ALx/Dq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8Orw6vDq8OoULYBiwLnSifORGEAuuL2VTTBUbwRP7KnRMHWwVj+WpolJC1HocqK7gsb46FSJkUFCYpCTKSGWImN8lfJqxMTE9J1p6G2MLbnajeKw0Gx6M5oGlBIC7YvyoYgSWpJRgTsFITowkZHH6p4Qe6obTbe1MioCc4k+qg2O1QbHaoNjtUGx2qDY7VBsdqg2O1QbHaoNjtUGx2qDY7VBsdqg2O1QbHaoNjtUGx2qDY7VBsdqg2O1QbHaoNjtUGx2qDY7VBsdqQCYO1LAKWMlDoSFKpLbBCXL5p9kMhDmI62KicoJSzQ6WKQ6THqSbs55ULoQWcmRe1s0ChjRPBMc6ROFG6KqTEaWqDY7VO2yhKESHFZIo1nARi7qhQMIMNwdRMTstBWlW9ckAOc2KOI24FlUvS7pW/0IIO1SrDKij+5TTBlTmnOeL8vXnSWPApvaIdyNKBnTLIXtB202obTgqF0InrFWK1txYgi3w0vF0QCNiD904sbQAIIsaWpBXciTpA+n3ObU23jEHJI2bFGp1iIQ6l586CKIhtaEE72aAYiQbbQQRtaonlRCF4IJ3tQ2DHTECCNrNBhIYQZDETszeghBAYwQQRtnh//9k="
之前网上的做法是将img从py文件import,然后进行解码到图片,然后再进行加载
import base64
tmp = open('one.jpg', 'wb') # 创建临时的文件
tmp.write(base64.b64decode(img)) ##把这个one图片解码出来,写入文件中去。
tmp.close()
self.label_19.setPixmap(QtGui.QPixmap('one.jpg'))
在调试的时候可以显示,但exe文件只会生成one.jpg文件,并不会自动加载进行。所以我的想法是,不保存文件,直接解码成图片文件。
import base64
from PIL import Image
from io import BytesIO
x = base64.b64decode(img)
imm = Image.open(BytesIO(x))
pixmap = imm.toqpixmap()
self.label_19.setPixmap(QtGui.QPixmap(pixmap))
亲测可行。