Re: Importing XMP data with SemWeb



Larry Ewing wrote:
It is following the XMP specification for keywords.  It creates triple
with a dc:Subject predicate and points that to the rdf bag with the
keywords.  We could easily extend way it stores this by defining some
custom predicates that hold more info but what is there now is the most
interoperable way of storing tags/keywords.

That doesn't seem to be what is happening, unless I'm missing something. I added some code that does the following:

	XmpFile xmp = Photo.UpdateXmp(photo,null);
	string xmppath = photo.Path + ".xmp";
	using (System.IO.FileStream stream = System.IO.File.OpenWrite (xmppath)) {
		System.Console.WriteLine("Saving xmp to " + xmppath);
		xmp.Save(stream);
	}

To see what xmp is being generated for a photo with 3 tags, and the resulting xmp data looked like this (with whitespace added to make it more readable:
<?xpacket begin="" id="testing"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/">
<rdf:RDF xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"; xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"; xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"; xmlns:xmpBJ="http://ns.adobe.com/xap/1.0/bj/"; xmlns:xmpidq="http://ns.adobe.com/xmp/Identifier/qual/1.0"; xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:xmp="http://ns.adobe.com/xap/1.0/"; xmlns:tiff="http://ns.adobe.com/tiff/1.0/"; xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/"; xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"; xmlns:exif="http://ns.adobe.com/exif/1.0/";>
  <rdf:Bag rdf:nodeID="anon0">
    <rdf:li>People</rdf:li>
    <rdf:li>Places</rdf:li>
    </rdf:Bag>
  <rdf:Description rdf:about="">
      <dc:subject rdf:nodeID="anon0" />
  </rdf:Description></rdf:RDF>
</x:xmpmeta>
<?xpacket end="r"?>

so it seems to be creating an description node with an empty subject node, and then putting the bag at the top level. Possibly I'm doing something wrong here. I'm currently working with the 0.1.11 snapshot - I haven't tried the cvs version yet...

However, with Bengt's pointer to the iptc site, I found a few sample jpegs with xmp data in them already, and it looks like you are right --- I think the 'approved' way to do something like this would look like the attached xmp file. I basically sucked the xmp out of one of the samples, deleted most of the IPTC entities and simplified the list of subjects. This is what I'm trying to get importing now. You can see an example the attachment IMG_5299.jpg.xmp

With semweb this is definitely a pain (look at the places in f-spot that
use the XMP directly for the lame hacks I did), but the semweb code for
reading and writing handled what I needed.  Someone could easily use the
triples to create a walkable graph and I'd be very happy if they did. I
haven't gotten to it yet.

Well - I've been trying to do that, but I'm not having much luck at all... I've written code that reads an xmp sidecar while importing (<file>.xmp) - it wasn't that hard, I'm just doing

	// check for an xmp "sidecar" file
	System.Console.WriteLine("looking for xmp file :" + origPath + ".xmp");
	if (System.IO.File.Exists(origPath + ".xmp")) {
		XmpFile sidecar = new XmpFile(System.IO.File.OpenRead(origPath + ".xmp"));
		sidecar.Dump();
	}
				

The output I'm getting is in IMG_5299.jpg.xmp.dump --- it looks to me like it's creating a triple for the close of the creator node, and for the opening of the bag, but *not* for the opening of the dc:subject containing the bag...

I'm not sure where to go from here. How attached are we to SemWeb? What I'm trying to do seems like it'd be a heck of a lot easier with a stock XML parser... anything that provides DOM style access should make this trivial.

I'm running into some other architectural issues on the import front, related to creating tags from within the FileImportBackEnd class, but I think I'll spawn another message to discuss that...

Thanks,

Warren


<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 3.0-28, framework 1.6'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>

 <rdf:Description rdf:about='uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9'
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:format>image/jpeg</dc:format>
  <dc:description>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>After digging the furrows another ten yards with the tractor, Jim Moore hops off to hand-set more leeks and onions.</rdf:li>
   </rdf:Alt>
  </dc:description>
  <dc:title>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>01661gdx</rdf:li>
   </rdf:Alt>
  </dc:title>
  <dc:rights>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>©2003 Big Newspaper, all rights reserved</rdf:li>
   </rdf:Alt>
  </dc:rights>
  <dc:creator>
   <rdf:Seq>
    <rdf:li>John Doe</rdf:li>
   </rdf:Seq>
  </dc:creator>
  <dc:subject>
   <rdf:Bag>
    <rdf:li>subject 1</rdf:li>
    <rdf:li>subject 2</rdf:li>
    <rdf:li>subject 3</rdf:li>
   </rdf:Bag>
  </dc:subject>
 </rdf:Description>

</rdf:RDF>
</x:xmpmeta>
<uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9> <http://purl.org/dc/elements/1.1/format> "image/jpeg".
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> "After digging the furrows another ten yards with the tractor, Jim Moore hops off to hand-set more leeks and onions."@x-default.
<uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9> <http://purl.org/dc/elements/1.1/description> <_>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> "01661gdx"@x-default.
<uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9> <http://purl.org/dc/elements/1.1/title> <_>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Alt>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> "\u00A92003 Big Newspaper, all rights reserved"@x-default.
<uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9> <http://purl.org/dc/elements/1.1/rights> <_>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> "John Doe".
<uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9> <http://purl.org/dc/elements/1.1/creator> <_>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag>.
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> "subject 1".
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> "subject 2".
<_> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> "subject 3".
<uuid:0f410644-9396-11d9-bb8e-a67e6693b6e9> <http://purl.org/dc/elements/1.1/subject> <_>.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]