In this code we will put some text into a png file (not in the image, but in the metadata) and then we will recover them for our need. I want to use the text in the image for an app I am making and that I will show you in the next days. We will use the PIL module. In case you do not have it, install it like this:
pip install pillow
from PIL import Image, PngImagePlugin info = PngImagePlugin.PngInfo() info.add_text("text", "This is the text I stored in a png") info.add_text("ZIP", "VALUE", zip=True) im = Image.open("001.png") im.save("001.png", "PNG", pnginfo=info) im3 = Image.open("001.png") #print(im3.info["text"]) print(im3.text["text"])
Live coding video of chunk text in a png file
Subscribe to the newsletter for updates
Tkinter templates
My youtube channel
Twitter: @pythonprogrammi - python_pygame