[gimp/gimp-2-10] plug-ins: interpret Exif.Photo.UserComment before showing in metadata-viewer.
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] plug-ins: interpret Exif.Photo.UserComment before showing in metadata-viewer.
- Date: Mon, 22 Mar 2021 20:30:45 +0000 (UTC)
commit 7b1f6e69dc3b5d425073066864b18147b3b90537
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon Mar 22 15:24:39 2021 -0400
plug-ins: interpret Exif.Photo.UserComment before showing in metadata-viewer.
(cherry picked from commit 34463786b175edbd883cc4ea52f087ebbd3d4c2a)
# Conflicts:
# plug-ins/metadata/metadata-viewer.c
plug-ins/metadata/metadata-viewer.c | 44 +++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
---
diff --git a/plug-ins/metadata/metadata-viewer.c b/plug-ins/metadata/metadata-viewer.c
index ce48393a49..1efbc6cd69 100644
--- a/plug-ins/metadata/metadata-viewer.c
+++ b/plug-ins/metadata/metadata-viewer.c
@@ -391,6 +391,39 @@ metadata_dialog_add_translated_tag (GExiv2Metadata *metadata,
g_free (value);
}
+static gchar *
+metadata_interpret_user_comment (gchar *comment)
+{
+ /* Exiv2 can return unwanted text at the start of a comment
+ * taken from Exif.Photo.UserComment since 0.27.3.
+ * Let's remove that part and replace with an empty string
+ * if there is nothing else left as comment. */
+
+ if (comment && g_str_has_prefix (comment, "charset=Ascii "))
+ {
+ gchar *real_comment;
+
+ /* Skip "charset=Ascii " (length 14) to find the real comment */
+ real_comment = comment + 14;
+ if (real_comment[0] == '\0' ||
+ ! g_strcmp0 (real_comment, "binary comment"))
+ {
+ g_free (comment);
+ /* Make empty comment instead of returning NULL or else
+ * the exif value will not be shown at all. */
+ comment = g_strdup ("");
+ }
+ else
+ {
+ real_comment = g_strdup (real_comment);
+ g_free (comment);
+ return real_comment;
+ }
+ }
+
+ return comment;
+}
+
static void
metadata_dialog_append_tags (GExiv2Metadata *metadata,
gchar **tags,
@@ -529,6 +562,17 @@ metadata_dialog_append_tags (GExiv2Metadata *metadata,
gps_done = TRUE;
}
}
+ else if (! strcmp ("Exif.Photo.UserComment", tag))
+ {
+ value = gexiv2_metadata_get_tag_interpreted_string (metadata, tag);
+ /* Can start with charset. Remove part that is not relevant. */
+ value = metadata_interpret_user_comment (value);
+
+ metadata_dialog_add_tag (store, iter,
+ tag_column, value_column,
+ tag, value);
+ g_free (value);
+ }
else
{
value = metadata_dialog_format_tag_value (metadata, tag,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]