[tracker/writeback] Added a few fields to the XMP writeback support



commit 1d8e4bfdc4e02288e7d2230cf5aa56665765ee8e
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Dec 15 15:00:39 2009 +0100

    Added a few fields to the XMP writeback support

 data/ontologies/38-nmm.ontology               |   21 +++--
 src/tracker-writeback/tracker-writeback-xmp.c |  134 +++++++++++++++++--------
 2 files changed, 105 insertions(+), 50 deletions(-)
---
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index 622f382..c3dd1d3 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -330,7 +330,8 @@ nmm:exposureTime a rdf:Property ;
 	rdfs:comment "Exposure time of the photo" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:Flash a rdfs:Class ;
 	rdfs:label "Flash values" ;
@@ -344,28 +345,32 @@ nmm:flash a rdf:Property ;
 	rdfs:comment "Specifies whether flash was used" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range nmm:Flash .
+	rdfs:range nmm:Flash ;
+	tracker:writeback true .
 
 nmm:fnumber a rdf:Property ;
 	rdfs:label "F number" ;
 	rdfs:comment "The diameter of the entrance pupil in terms of the focal length of the lens" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:focalLength a rdf:Property ;
 	rdfs:label "Focal length" ;
 	rdfs:comment "A measure of how strongly the lens converges light" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:isoSpeed a rdf:Property ;
 	rdfs:label "ISO speed" ;
 	rdfs:comment "Measure of a photographic film's sensitivity to light as ISO value" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:MeteringMode a rdfs:Class ;
 	rdfs:label "Metering mode values" ;
@@ -383,7 +388,8 @@ nmm:meteringMode a rdf:Property ;
 	rdfs:comment "Metering mode refers to the way in which a camera determines the exposure." ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range nmm:MeteringMode .
+	rdfs:range nmm:MeteringMode ;
+	tracker:writeback true .
 
 nmm:WhiteBalance a rdfs:Class ;
 	rdfs:label "White balance" ;
@@ -395,7 +401,8 @@ nmm:white-balance-manual a nmm:WhiteBalance .
 nmm:whiteBalance a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range nmm:WhiteBalance .
+	rdfs:range nmm:WhiteBalance ;
+	tracker:writeback true .
 
 nmm:isCropped a rdf:Property ;
 	nrl:maxCardinality 1 ;
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index 8135bb9..daa2dba 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -204,55 +204,103 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 		}
 
 		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "orientation") == 0) {
-			guint i;
-
-			static const gchar *ostr[8] = {
-				/* 0 */ TRACKER_NFO_PREFIX "orientation-top",
-				/* 1 */ TRACKER_NFO_PREFIX "orientation-top-mirror",
-				/* 2 */ TRACKER_NFO_PREFIX "orientation-bottom",
-				/* 3 */ TRACKER_NFO_PREFIX "orientation-bottom-mirror",
-				/* 4 */ TRACKER_NFO_PREFIX "orientation-left-mirror",
-				/* 5 */ TRACKER_NFO_PREFIX "orientation-right",
-				/* 6 */ TRACKER_NFO_PREFIX "orientation-right-mirror",
-				/* 7 */ TRACKER_NFO_PREFIX "orientation-left"
-			};
 
 			xmp_delete_property (xmp, NS_EXIF, "Orientation");
 
-			for (i=0; i < 8; i++) {
-				if (g_strcmp0 (row[2], ostr[i]) == 0) {
-					switch (i) {
-					case 0:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "top - left", 0);
-						break;
-					case 1:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "top - right", 0);
-						break;
-					case 2:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - right", 0);
-						break;
-					case 3:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - left", 0);
-						break;
-					case 4:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "left - top", 0);
-						break;
-					case 5:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "right - top", 0);
-						break;
-					case 6:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "right - bottom", 0);
-						break;
-					case 7:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "left - bottom", 0);
-						break;
-					default:
-						break;
-					}
-				}
+			if        (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-top") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "top - left", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-top-mirror") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "top - right", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-bottom") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - right", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-bottom-mirror") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - left", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-left-mirror") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "left - top", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-right") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "right - top", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-right-mirror") == 0) {
+					xmp_set_property (xmp, NS_EXIF, "Orientation", "right - bottom", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-left") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "left - bottom", 0);
 			}
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "meteringMode") == 0) {
+
+			xmp_delete_property (xmp, NS_EXIF, "MeteringMode");
+
+			/* 0 = Unknown
+			   1 = Average
+			   2 = CenterWeightedAverage
+			   3 = Spot
+			   4 = MultiSpot
+			   5 = Pattern
+			   6 = Partial
+			   255 = other  */
+
+			if        (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-center-weighted-average") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "center", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-average") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "average", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-spot") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "spot", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-multispot") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "multispot", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-pattern") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "pattern", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-partial") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "partial", 0);
+			} else {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "other", 0);
+			}
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "whiteBalance") == 0) {
+
+			xmp_delete_property (xmp, NS_EXIF, "WhiteBalance");
+
+			if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "whiteBalance-auto") == 0) {
+				/* 0 = Auto white balance
+				 * 1 = Manual white balance */
+				xmp_set_property (xmp, NS_EXIF, "WhiteBalance", "auto", 0);
+			} else {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "manual", 0);
+			}
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "flash") == 0) {
+
+			xmp_delete_property (xmp, NS_EXIF, "Flash");
+
+			if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "flash-on") == 0) {
+				/* 0 = Flash did not fire
+				   1 = Flash fired */
+				xmp_set_property (xmp, NS_EXIF, "Flash", "on", 0);
+			} else {
+				xmp_set_property (xmp, NS_EXIF, "Flash", "off", 0);
+			}
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "focalLength") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "FocalLength");
+			xmp_set_property (xmp, NS_EXIF, "FocalLength", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "exposureTime") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "ExposureTime");
+			xmp_set_property (xmp, NS_EXIF, "ExposureTime", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "isoSpeed") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "ISOSpeedRatings");
+			xmp_set_property (xmp, NS_EXIF, "ISOSpeedRatings", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "fnumber") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "FNumber");
+			xmp_set_property (xmp, NS_EXIF, "FNumber", row[2], 0);
+		}
 
 		/*
 		  if (g_strcmp0 (row[1], PHOTO_HAS "contact") == 0) {



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