RDF in PNG

A long-running goal of mine is to write a image gallery for my web page, so the screenshot and photo galleries can have categories, titles, dates, etc. Being a fan of metadata, XML, Dublin Core etc, I've planned to do this by embedding the metadata into the image files instead of relying on a database.

A little poking and emailing comes up with interesting links. Dave Beckett has embedded RDF into a PNG by using a tEXt field called 'Metadata'. However, he doesn't have any nice tools to do this and usually uses pnmtopng (which allows the user to specify text chunks). I poked a libpng but that doesn't really allow me to fiddle with the chunks.

So I'm announcing PyPNG! A very small and rather poor Python (plus a smidge of C to do CRCs) library with grand ambitions. At the moment I can copy a PNG file (by reading the chunks, and then writing them again), display the text chunks, et la piece de resistance: a tool to set the content of an arbitary text chunk! PNGs with embedded RDF, here I come.

Once I've fiddled with the library design a little I'll write a PNG Explorer (hmm, png:/// in Nautilus is tempting) and a Metadata Editor for PNG files. Then I'll try and do exactly the same for JPEG files. Finally of course I'll have to write the web front-end.

No downloads yet, but if you want the source ask for it. Hopefully I'll have a sane tarball of PyPNG done this week though.

09:48 Wednesday, 28 Jan 2004 [#] [computers] (13 comments)

Posted by Albert Mora at Wed Jan 28 12:13:33 2004:
Have you thought in adding this comment support to F-Spot? This could be a good way to give data to your photos and a way to help the program organize it (smart albums, some pics suggested, some related pics...).

Anyway, I like the idea of adding info to my pictures. It could be useful in many ways...

albert...
Posted by Andi at Wed Jan 28 12:53:04 2004:
I'm doing this with jpeg files. Have a look at my 'My Pictures' Gallery (see url). All Metadata is sored with in the pictures. Even searching is possible.
Posted by Ross at Wed Jan 28 13:40:53 2004:
Albert -- yes, Edd suggested this and I'm thinking about using this as a learning exercise in C#.

Andi -- nice.  I'd probably extend that idea to store the thumbnails inside the image files, and of course use RDF more. The concepts are very similar though.
Posted by Gnomer at Wed Jan 28 14:21:57 2004:
Isn't EXIF what you want here?  Why worry about a different file format?  Do the metadata tags in EXIF not hold enough for you?

Personally, I run a photogallery on my website where I query all the EXIF tags for date and time, camera settings, as well as programmable tags such as comment, latitute/longitude, and photographer.

There are plenty of blank tags, and I'm sure there is one that could be used for embedding RDF, like here.  I know that I've certainly embedded HTML into the comment tag before.
Posted by Gnomer at Wed Jan 28 14:24:00 2004:
As well, EXIF has a specific tag where you are meant to store the thumbnail.
Posted by Ross at Wed Jan 28 14:24:11 2004:
Gnomer -- EXIF works well for JPEG but not so well for PNG, and I'm an XML kinda guy when it comes down to it.
Posted by Gnomer at Wed Jan 28 15:07:36 2004:
Well, just make sure that you don't throw the EXIF information away.  Personally, I like the fact that I can take a photo from anyone's digital camera, throw it into a directory on my website, and have the date/time appear.  It would be a shame to trash that data.

The problems with additional formats is that it means additional software, with additional libraries, with addition frontends, with additional ...
Posted by Marcus at Wed Jan 28 21:23:59 2004:
Well, have you looked at RDFPic? It seems like Yves Lafon and Bert Bos from W3 have already worked on something similar, and have a Java GUI application for adding metadata to PNG images. Check it out at

http://jigsaw.w3.org/rdfpic/
http://www.w3.org/TR/photo-rdf/

Of course, it would be nicer to have it on libpng, and extend it for other image formats, but checking their work out may save you some time.
Posted by albertob at Thu Jan 29 10:05:56 2004:
Concerning RDF and JPEG, have a look at Norm Walsh's jpegrdf. It's written in Java using Jena RDF store.
Posted by Martin Kretzschmar at Thu Jan 29 10:08:15 2004:
Another link for png-mangling:

http://sng.sourceforge.net/

"SNG is implemented by a compiler/decompiler called sng that losslessly translates between SNG and PNG."

SNG being a plain text representation of PNG.

I never used it though ;)
Posted by Ross at Thu Jan 29 10:30:43 2004:
Gnomer -- of course I shall keep the EXIF chunk, its very useful. I might transform it into RDF as well though..

jpegrdf, sng, rdfpic I've all seen and examined.  I did loads of research before starting :)
Posted by Gary at Thu May 6 13:06:25 2004:
Have you had a look at <a href="http://archive.dstc.edu.au/RDU/staff/jane-hunter/PNG/paper.html">An Indexing and Querying System for Online Images
Based on the PNG Format and Embedded Metadata

. It uses DC Metadata with PNG, unfortunately nothing acutally seems to be available to the public. I'm trying to store large volumes of images with their metadata attached (and hopefully one day searchable).

Using an XML format (and pre-exisiting metadata formats make sense) is great as potientially the format can be further extended such as by adding SVG regions as proposed by Kanzaki and others.

So yeah, I'm interested in your project :).
Posted by Gary at Thu May 6 13:07:52 2004:
Sorry about the messed up HTML link, I don't know what I was thinking.

Looks at floor in shame

Name:


E-mail:


URL:


Add 8 and 1 (required):


Comment: