Here's another patch - it builds on top of the previous patch, and adds
two things:
- if a photoshop Headline node is found, it's contents are added to
the photo's Description (which shows up as Comment in the GUI). I don't
know enough RDF/XMP to know if this is a fully general solution, but it
works on the XMP data Bengt sent. This would probably be easy to extend
to grab other photoshop tags and do sensible things with them --- if we
can figure out what the sensible things are...
- newly created tags are added under an "Imported Tags" category.
If such a Category doesn't exist, it's created as a top-level category
Before I add this to a bug I'll merge the two patches...
Bengt - here's a hack you might want to try. I don't know how
repeatable the XMP data you have is, but in the sample you sent me the
dc:subject Bag was the very first bag encountered in the XMP data. the
following patch will modify the import code to stop after the first Bag
it processes. If the dc:subject Bag is always the first, then this will
eliminate all of the other garbage tags you are seeing.
diff -ur clean/f-spot-0.1.11/src/MetadataStore.cs
f-spot-0.1.11/src/MetadataStore.cs
--- clean/f-spot-0.1.11/src/MetadataStore.cs 2006-04-21
18:35:35.000000000 -0400
+++ f-spot-0.1.11/src/MetadataStore.cs 2006-04-21 18:38:11.000000000 -0400
@@ -208,7 +208,7 @@
if (savingTags) {
if (stmt.Object.ToString() == "_") {
savingTags = false;
- continue;
+ break;
}
string tag = stmt.Object.ToString();
// SemWeb puts quotes around the
strings it returns,
In a pinch it wouldn't be that hard to add a special case to ignore
Author,* creator,* and Location,* tags...
Warren
diff -ur clean/f-spot-0.1.11/src/FileImportBackend.cs
f-spot-0.1.11/src/FileImportBackend.cs
--- clean/f-spot-0.1.11/src/FileImportBackend.cs 2006-04-21
18:35:35.000000000 -0400
+++ f-spot-0.1.11/src/FileImportBackend.cs 2006-04-21 18:20:30.000000000
-0400
@@ -177,6 +177,20 @@
// check for an xmp "sidecar" file
if (System.IO.File.Exists(origPath + ".xmp")) {
XmpFile sidecar = new
XmpFile(System.IO.File.OpenRead(origPath + ".xmp"));
+
+ // if we find a photoshop:Headline node than
put it's content in the description field.
+ foreach (SemWeb.Statement stmt in
sidecar.Store) {
+ if (stmt.Predicate.ToString() ==
"http://ns.adobe.com/photoshop/1.0/Headline") {
+ string description =
stmt.Object.ToString();
+ // SemWeb puts quotes around
the strings it returns,
+ // so we need to remove them
+ if
(description.StartsWith("\"") && description.EndsWith("\"")) {
+ description =
description.Substring(1,description.Length-2);
+ }
+ photo.Description = description;
+ }
+ }
+
string [] tagNames =
sidecar.Store.GetTagNames();
foreach (string tagName in tagNames) {
System.Console.WriteLine("adding tag
for: " + tagName);
diff -ur clean/f-spot-0.1.11/src/PhotoStore.cs f-spot-0.1.11/src/PhotoStore.cs
--- clean/f-spot-0.1.11/src/PhotoStore.cs 2006-04-21 18:35:35.000000000
-0400
+++ f-spot-0.1.11/src/PhotoStore.cs 2006-04-21 18:29:56.000000000 -0400
@@ -636,15 +636,20 @@
}
// Lookup a tag by name --- needed for importing tags
- // If the requested tag doesn't exist, a new top-level tag
- // is created and returned.
+ // If the requested tag doesn't exist, a new Category inside
+ // the top level category "Imported Tags" is created and returned.
+ // if "Imported Tags" doesn't exist, it is created.
public Tag GetTagByName (string name) {
Tag tag = tag_store.GetTagByName(name);
if (tag == null) {
- tag = tag_store.CreateCategory(null,name);
+ Category importedTags =
(Category)tag_store.GetTagByName("Imported Tags");
+ if (importedTags == null) {
+ importedTags =
tag_store.CreateCategory(null,"Imported Tags");
+ }
+ tag = tag_store.CreateCategory(importedTags,name);
}
return tag;
}
_______________________________________________
F-spot-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/f-spot-list