Commit 08fcb249 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

fixed saving of Xmp and Iptc description and title fields

[bug #626284]
parent 037456a4
......@@ -144,8 +144,8 @@ const char *_DESCRIPTION_TAG_NAMES[] = {
"Exif::Image::ImageDescription",
"Xmp::dc::description",
"Xmp::tiff::ImageDescription",
"Iptc::Application2::Caption",
"Iptc::Application2::Headline",
"Iptc::Application2::Caption",
NULL
};
......@@ -271,24 +271,15 @@ set_file_info (GFileInfo *info,
static void
set_attribute_from_tagset (GFileInfo *info,
const char *attribute,
const char *tagset[])
set_attribute_from_metadata (GFileInfo *info,
const char *attribute,
GObject *metadata)
{
GObject *metadata;
int i;
char *key;
char *description;
char *formatted_value;
char *raw_value;
char *type_name;
metadata = NULL;
for (i = 0; tagset[i] != NULL; i++) {
metadata = g_file_info_get_attribute_object (info, tagset[i]);
if (metadata != NULL)
break;
}
char *key;
char *description;
char *formatted_value;
char *raw_value;
char *type_name;
if (metadata == NULL)
return;
......@@ -300,6 +291,7 @@ set_attribute_from_tagset (GFileInfo *info,
"raw", &raw_value,
"value-type", &type_name,
NULL);
set_file_info (info,
attribute,
description,
......@@ -310,6 +302,26 @@ set_attribute_from_tagset (GFileInfo *info,
}
static void
set_attribute_from_tagset (GFileInfo *info,
const char *attribute,
const char *tagset[])
{
GObject *metadata;
int i;
metadata = NULL;
for (i = 0; tagset[i] != NULL; i++) {
metadata = g_file_info_get_attribute_object (info, tagset[i]);
if (metadata != NULL)
break;
}
if (metadata != NULL)
set_attribute_from_metadata (info, attribute, metadata);
}
static void
set_string_list_attribute_from_tagset (GFileInfo *info,
const char *attribute,
......@@ -350,6 +362,26 @@ set_attributes_from_tagsets (GFileInfo *info)
set_attribute_from_tagset (info, "general::description", _DESCRIPTION_TAG_NAMES);
set_attribute_from_tagset (info, "general::title", _TITLE_TAG_NAMES);
/* if iptc::caption and iptc::headline are different use iptc::caption
* to set general::title, if not alreay set. */
if (g_file_info_get_attribute_object (info, "general::title") == NULL) {
GObject *iptc_caption;
GObject *iptc_headline;
iptc_caption = g_file_info_get_attribute_object (info, "Iptc::Application2::Caption");
iptc_headline = g_file_info_get_attribute_object (info, "Iptc::Application2::Headline");
if ((iptc_caption != NULL)
&& (iptc_headline != NULL)
&& (g_strcmp0 (gth_metadata_get_raw (GTH_METADATA (iptc_caption)),
gth_metadata_get_raw (GTH_METADATA (iptc_headline))) != 0))
{
set_attribute_from_metadata (info, "general::title", iptc_caption);
}
}
set_attribute_from_tagset (info, "general::location", _LOCATION_TAG_NAMES);
set_string_list_attribute_from_tagset (info, "general::tags", _KEYWORDS_TAG_NAMES);
set_attribute_from_tagset (info, "Embedded::Photo::DateTimeOriginal", _ORIGINAL_DATE_TAG_NAMES);
......
......@@ -134,11 +134,28 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
metadata = g_file_info_get_attribute_object (file_data->info, "general::description");
if (metadata != NULL) {
const char *tags_to_remove[] = {
"Exif::Image::ImageDescription",
"Xmp::tiff::ImageDescription",
"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]);
g_file_info_set_attribute_object (file_data->info, "Exif::Photo::UserComment", metadata);
g_file_info_set_attribute_object (file_data->info, "Xmp::dc::description", metadata);
g_file_info_set_attribute_object (file_data->info, "Iptc::Application2::Headline", metadata);
}
metadata = g_file_info_get_attribute_object (file_data->info, "general::title");
if (metadata != NULL) {
g_file_info_set_attribute_object (file_data->info, "Xmp::dc::title", metadata);
g_file_info_set_attribute_object (file_data->info, "Iptc::Application2::Caption", metadata);
}
metadata = g_file_info_get_attribute_object (file_data->info, "general::location");
if (metadata != NULL) {
g_file_info_set_attribute_object (file_data->info, "Xmp::iptc::Location", metadata);
......
......@@ -46,6 +46,10 @@ GthMetadataCategory exiv2_metadata_category[] = {
GthMetadataInfo exiv2_metadata_info[] = {
/* Specify the type of a field to allow to create it if it's not
* already present in the image. */
{ "Exif::Image::Make", NULL, "Exif::General", 1, NULL, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Exif::Image::Model", NULL, "Exif::General", 2, NULL, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Exif::Image::Software", NULL, "Exif::General", 3, NULL, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
......@@ -142,6 +146,16 @@ GthMetadataInfo exiv2_metadata_info[] = {
{ "Exif::Photo::MakerNote", NULL, "Exif::Other", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
{ "Xmp::dc::description", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "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 },
{ "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 },
{ "Iptc::Application2::LocationName", NULL, "Iptc", 0, "String", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Iptc::Application2::Keywords", NULL, "Iptc", 0, "String", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ NULL, NULL, NULL, 0, NULL, 0 }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment