Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

can i save additional information with png file

from PIL.PngImagePlugin import PngImageFile, PngInfo

targetImage = PngImageFile("pathToImage.png")

metadata = PngInfo()
metadata.add_text("MyNewString", "A string")
metadata.add_text("MyNewInt", str(1234))

targetImage.save("NewPath.png", pnginfo=metadata)
targetImage = PngImageFile("NewPath.png")

print(targetImage.text)

>>> {'MyNewString': 'A string', 'MyNewInt': '1234'}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #save #additional #information #png #file
ADD COMMENT
Topic
Name
5+4 =