[gthumb] Changed exif/xmp tag where the date is saved



commit 74564d140eb7497617ee76ad8d2a1bde7e2c0fd7
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jul 20 12:31:31 2011 +0200

    Changed exif/xmp tag where the date is saved
    
    Save the date entered in the edit metadata dialog in
    Exif::Photo::DateTimeOriginal and in Xmp::exif::DateTimeOriginal
    Use Exif::Image::DateTime to save the last modified date.
    This fixes an error that prevented to delete the date from an image
    with the edit metadata dialog.

 extensions/exiv2_tools/exiv2-utils.cpp             |    5 +--
 extensions/exiv2_tools/exiv2-utils.h               |    4 ++
 .../exiv2_tools/gth-metadata-provider-exiv2.c      |   47 ++++++++++++--------
 extensions/exiv2_tools/main.c                      |    1 +
 4 files changed, 35 insertions(+), 22 deletions(-)
---
diff --git a/extensions/exiv2_tools/exiv2-utils.cpp b/extensions/exiv2_tools/exiv2-utils.cpp
index 45f3513..7d82f2d 100644
--- a/extensions/exiv2_tools/exiv2-utils.cpp
+++ b/extensions/exiv2_tools/exiv2-utils.cpp
@@ -500,10 +500,7 @@ set_attributes_from_tagsets (GFileInfo *info)
 	clear_studip_comments_from_tagset (info, _DESCRIPTION_TAG_NAMES);
 	clear_studip_comments_from_tagset (info, _TITLE_TAG_NAMES);
 
-	set_attribute_from_tagset (info, "general::datetime", _LAST_DATE_TAG_NAMES);
-	if (g_file_info_get_attribute_object (info, "general::datetime") == NULL)
-		set_attribute_from_tagset (info, "general::datetime", _ORIGINAL_DATE_TAG_NAMES);
-
+	set_attribute_from_tagset (info, "general::datetime", _ORIGINAL_DATE_TAG_NAMES);
 	set_attribute_from_tagset (info, "general::description", _DESCRIPTION_TAG_NAMES);
 	set_attribute_from_tagset (info, "general::title", _TITLE_TAG_NAMES);
 
diff --git a/extensions/exiv2_tools/exiv2-utils.h b/extensions/exiv2_tools/exiv2-utils.h
index 4a1595c..cf44fb3 100644
--- a/extensions/exiv2_tools/exiv2-utils.h
+++ b/extensions/exiv2_tools/exiv2-utils.h
@@ -28,6 +28,10 @@
 
 G_BEGIN_DECLS
 
+extern const char *_LAST_DATE_TAG_NAMES[];
+extern const char *_ORIGINAL_DATE_TAG_NAMES[];
+extern const char *_DESCRIPTION_TAG_NAMES[];
+
 gboolean   exiv2_read_metadata_from_file    (GFile           *file,
 					     GFileInfo       *info,
 					     GCancellable    *cancellable,
diff --git a/extensions/exiv2_tools/gth-metadata-provider-exiv2.c b/extensions/exiv2_tools/gth-metadata-provider-exiv2.c
index b26aa79..71f138d 100644
--- a/extensions/exiv2_tools/gth-metadata-provider-exiv2.c
+++ b/extensions/exiv2_tools/gth-metadata-provider-exiv2.c
@@ -142,7 +142,6 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider   *self,
 			"Iptc::Application2::Caption",
 			NULL
 		};
-		int i;
 
 		for (i = 0; tags_to_remove[i] != NULL; i++)
 			g_file_info_remove_attribute (file_data->info, tags_to_remove[i]);
@@ -169,19 +168,8 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider   *self,
 		}
 	}
 	else {
-		const char *tags_to_remove[] = {
-			"Exif::Image::ImageDescription",
-			"Xmp::tiff::ImageDescription",
-			"Iptc::Application2::Headline",
-			"Exif::Photo::UserComment",
-			"Xmp::dc::description",
-			"Iptc::Application2::Caption",
-			NULL
-		};
-		int i;
-
-		for (i = 0; tags_to_remove[i] != NULL; i++)
-			g_file_info_remove_attribute (file_data->info, tags_to_remove[i]);
+		for (i = 0; _DESCRIPTION_TAG_NAMES[i] != NULL; i++)
+			g_file_info_remove_attribute (file_data->info, _DESCRIPTION_TAG_NAMES[i]);
 	}
 
 	metadata = g_file_info_get_attribute_object (file_data->info, "general::title");
@@ -220,11 +208,34 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider   *self,
 
 	metadata = g_file_info_get_attribute_object (file_data->info, "general::datetime");
 	if (metadata != NULL) {
-		g_object_set (metadata, "value-type", NULL, NULL);
-		g_file_info_set_attribute_object (file_data->info, "Exif::Image::DateTime", metadata);
+		GthMetadata *xmp_metadata = NULL;
+		GTimeVal     timeval;
+
+		if (_g_time_val_from_exif_date (gth_metadata_get_raw (GTH_METADATA (metadata)), &timeval)) {
+			char *xmp_format;
+
+			xmp_metadata = gth_metadata_dup (GTH_METADATA (metadata));
+			xmp_format = _g_time_val_to_xmp_date (&timeval);
+			g_object_set (xmp_metadata, "raw", xmp_format, NULL);
+
+			g_free (xmp_format);
+		}
+
+		for (i = 0; _ORIGINAL_DATE_TAG_NAMES[i] != NULL; i++) {
+			if (g_str_has_prefix (_ORIGINAL_DATE_TAG_NAMES[i], "Xmp::")) {
+				if (xmp_metadata != NULL)
+					g_file_info_set_attribute_object (file_data->info, _ORIGINAL_DATE_TAG_NAMES[i], G_OBJECT (xmp_metadata));
+			}
+			else
+				g_file_info_set_attribute_object (file_data->info, _ORIGINAL_DATE_TAG_NAMES[i], metadata);
+		}
+
+		_g_object_unref (xmp_metadata);
+	}
+	else {
+		for (i = 0; _ORIGINAL_DATE_TAG_NAMES[i] != NULL; i++)
+			g_file_info_remove_attribute (file_data->info, _ORIGINAL_DATE_TAG_NAMES[i]);
 	}
-	else
-		g_file_info_remove_attribute (file_data->info, "Exif::Image::DateTime");
 
 	if (exiv2_write_metadata_to_buffer (&buffer,
 					    &size,
diff --git a/extensions/exiv2_tools/main.c b/extensions/exiv2_tools/main.c
index 5037c03..4ea8b85 100644
--- a/extensions/exiv2_tools/main.c
+++ b/extensions/exiv2_tools/main.c
@@ -151,6 +151,7 @@ GthMetadataInfo exiv2_metadata_info[] = {
 	{ "Xmp::dc::title", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
 	{ "Xmp::iptc::Location", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
 	{ "Xmp::iptc::Keywords", NULL, "Xmp::Embedded", 0, "XmpBag", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+	{ "Xmp::exif::DateTimeOriginal", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
 
 	{ "Iptc::Application2::Headline", NULL, "Iptc", 0, "String", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
 	{ "Iptc::Application2::Caption", NULL, "Iptc", 0, "String", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },



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