How to allow writing and reading meta data

35 views
Skip to first unread message

Almar Klein

unread,
Jun 1, 2012, 7:46:35 AM6/1/12
to ima...@googlegroups.com
We need a way to allow the user easy access to the meta data, and also to write a file with meta data. This can be very powerful, and is a simple necessity for scientific formats.

For functions that write an image this is easy: we can just include a keyword argument called "meta" which should be a dict.

From the current status of the discussion about reading multiple images, this seems to not be a problem either; we could add a get_meta() method to the reader object, akin to the get_image() method.

But what about imread()? Let me kick off with three ideas:
  - a separate function "metaread".
  - let imread return an array that has an extra "meta" attribute.
  - only allow reading via a reader object.

IMO, a separate function introduces extra "clutter" and somehow does not seem consistent with writing meta information; there is no metawrite. Also, it means that a file needs to be opened twice if you need both the data and the info.

I like that by returning an array with a meta attribute the image data and meta info are kept together. So if you pass the image to a function, that function can access the meta data too.

With the 3d option, I envision that you call a certain function ("read"?) that always returns a reader object. The user can then use that to read the image and/or the meta data. The advantage is that if the user only wants the meta information, the image data is not loaded.

Regards,
  Almar

Zach Pincus

unread,
Jun 21, 2012, 3:09:37 PM6/21/12
to ima...@googlegroups.com
Anyhow, I like the array-with-extra-attribute option. Should the reader try to load all metadata by default? Or just as an option? Default sounds nicer, and really isn't going to add much overhead in this day and age.

Alternately / also, a metaread() would be useful for times when you don't want to load the whole image.

A couple caveats:
1) Don't forget making sure to deal with the "metadata models" that FreeImage supports. 
2) Multipage images can be tricky vis a vis metadata. Sometimes the metadata is per-page, sometimes there is per-image metadata (I think). Making sure these two features interact nicely can be tricky.

Zach
Reply all
Reply to author
Forward
0 new messages