Write metadata to a png

Registered by Antonio Roberts on 2009-08-19

Attempt to add writing of metadata to a .png file there is no official way of doing this, other projects, such as Inkscape, support this (https://bugs.launchpad.net/inkscape/+bug/189954)

Blueprint information

Status:
Not started
Approver:
Stani
Priority:
High
Drafter:
Stani
Direction:
Needs approval
Assignee:
None
Definition:
Approved
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

http://stripit.svn.sourceforge.net/viewvc/stripit/trunk/stripit.py?view=markup
http://blog.modp.com/2007/08/python-pil-and-png-metadata-take-2.html
http://photobatch.wikidot.com/forum/t-88474/preserve-text-chunks

 #
 # wrapper around PIL 1.1.6 Image.save to preserve PNG metadata
 #
 # public domain, Nick Galbreath
 # http://blog.modp.com/2007/08/python-pil-and-png-metadata-take-2.html
 #
 def pngsave(self, im, file):
  # these can be automatically added to Image.info dict
  # they are not user-added metadata
  reserved = ('interlace', 'gamma', 'dpi', 'transparency', 'aspect')

  # undocumented class
  from PIL import PngImagePlugin
  meta = PngImagePlugin.PngInfo()

  # copy metadata into new object
  for k,v in im.info.iteritems():
   if k in reserved: continue
   meta.add_text(k, v, 0)

  # and save
  im.save(file, "PNG", pnginfo=meta)

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.