My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Intro  
OpenMeta - set and retrieve tags and other meta data in OS X.
Featured, Phase-Implementation
Updated Feb 4, 2010 by ironicsu...@gmail.com

Introduction

OpenMeta uses setxattr(), getxattr() in a consistent manner to set and retrieve tags, ratings, and other metadata.

Details

Please feel free to download and evaluate the source - which I should have up in Dec 2008:

  • Initially, all changes will go through me (tom), but if it gets busy I would not mind any help!

Basically, OpenMeta will:

1) Allow programs to set/retrieve tags, ratings, etc on files using a simple API. This api will enforce a few 'rules' about tags - (eg no duplicates, case insensitive, case preserving, etc). Rules are generally 'good' - they allow for consistent user experiences.

2) These tags are automatically indexed with Spotlight.

3) Uses no Apple 'secret' api.

4) Allows the setting of (non spotlight indexed) 'larger but still small (<4k)' blobs of meta data, such as workflows , etc.

There are a few 'gotchas' that we found while working this all out, which is one reason why we thought it was important to not only release the idea, but also some source to implement it.

There are more and more applications using OpenMeta: See OpenMetaApplications.

Comment by groble...@gmail.com, Jan 27, 2009

We're interested in attaching 'larger and no longer small' (<64K) metadata items to image files. Initially at least, these consist of auxiliary JPEG images. We can do it with XMP tags of type "thumbnail" but wonder if there might be an alternate approach. Typically we attach 1 or 2 such images but could need more.

Comment by project member tom.ande...@gmail.com, Mar 2, 2009

Hi,

The only way to do this is with the resource fork for a file - but if you are the only people that are using this system - could you not put the thumbs in any place you like, (even on an http server) then link to them with a path, url or alias in an xattr? I guess it depends on what and how you are using the images. Do you want them as the preview image in the Finder? Or is it for some internal caching system for an app, or are the images completely different from the original file?

All Adobe CS4 apps erase all resource fork data and xattr when ever they save a file. This is a big adobe bug. So - if your users are using photoshop, indesign, etc, then it is likely best to use XMP. XMP is the only thing that Adobe keeps on save. I don't know how XMP supports multiple thumbnails, etc. problems with XMP are large bloated code, complex, invasive, etc. Also the last time I tried, I could not get 64 bit versions of XMP to build.

Comment by panam...@gmail.com, Mar 3, 2009

Do you know if this code will work on an iPhone. I'd like to tag photos and retain the tags after syncing with the desktop.

Comment by groble...@gmail.com, Apr 2, 2009

The auxiliary images we need to store in the file are not just different versions of the main image--they are different images entirely. Thanks for the caveat re: Adobe. Another question is the feasibility of writing an iPhoto plug-in to display these embedded images?

Comment by project member tom.ande...@gmail.com, Jul 28, 2010

here is how to find all tagged files (actually this code returns all unique tags)

- (NSArray*) tagSearch
{
	MDQueryRef query = MDQueryCreate(NULL, (CFStringRef)@"kMDItemOMUserTags == *", (CFArrayRef) [NSArray arrayWithObject:@"kMDItemOMUserTags"], NULL);

	Boolean queryRan = MDQueryExecute(query, kMDQuerySynchronous);
	if(!queryRan)
	return NULL;

	CFIndex count = MDQueryGetResultCount(query);

	NSMutableSet * uniqueTags = [NSMutableSet set];
	CFArrayRef tagNames;

	CFIndex i;
	for(i = 0; i < count; i++)
	{
		tagNames = MDQueryGetAttributeValueOfResultAtIndex(query, (CFStringRef)@"kMDItemOMUserTags", i);
		if(tagNames != NULL)
		{
			[uniqueTags addObjectsFromArray:(NSArray *) tagNames];
		}
	}

	CFRelease(query);
	return [uniqueTags allObjects];
}

Sign in to add a comment
Powered by Google Project Hosting