📜  Qt 将图像转换为 base64 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.612000             🧑  作者: Mango

代码示例1
# Python Solution
# The PIL Module has a class that helps with this.
from PIL.ImageQt import ImageQt

image = PySide2.QtGui.QPixmap.toImage()
image = ImageQt(image)
# Now you have an object with PIL + Qt support.
import base64
from io import BytesIO

buffered = BytesIO()
image.save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue())