[gimp] libgimp: fix #1632 GIMP should not write to IPTC tag DateCreated
- From: Jacob Boerema <jboerema src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: fix #1632 GIMP should not write to IPTC tag DateCreated
- Date: Mon, 6 Jun 2022 23:03:41 +0000 (UTC)
commit 7231ea54f8c651b2a6d51ba601ba5cd5f7d0226f
Author: Jacob Boerema <jgboerema gmail com>
Date: Mon Jun 6 19:03:03 2022 -0400
libgimp: fix #1632 GIMP should not write to IPTC tag DateCreated
GIMP was saving the last changed/saved date to IPTC tag DateCreated,
which should only be used for the original creating date of the image
and thus should not be changed by GIMP.
After discussion in the cited issue, there is no tag in IPTC that we can
use, so we remove saving modified date from the IPTC metadata.
Instead we add two XMP tags, one for modified date and the other for the
date that metadata was changed. Since we do both when exporting, both are
saved with the same date/time in ISO 8601 format.
This also fixes another issue where we were not storing the timezone offset
for Xmp.tiff.DateTime. Since this has the same format as the other
XMP tags, we fix this together with this issue.
libgimp/gimpimagemetadata-save.c | 61 ++++++++++++++++------------------------
1 file changed, 25 insertions(+), 36 deletions(-)
---
diff --git a/libgimp/gimpimagemetadata-save.c b/libgimp/gimpimagemetadata-save.c
index 0920057a37..f656440256 100644
--- a/libgimp/gimpimagemetadata-save.c
+++ b/libgimp/gimpimagemetadata-save.c
@@ -92,7 +92,7 @@ gimp_image_metadata_save_prepare (GimpImage *image,
gdouble xres;
gdouble yres;
gchar buffer[32];
- gchar *str;
+ gchar *datetime_buf = NULL;
GExiv2Metadata *g2metadata = GEXIV2_METADATA (metadata);
image_width = gimp_image_get_width (image);
@@ -191,6 +191,28 @@ gimp_image_metadata_save_prepare (GimpImage *image,
g_clear_error (&error);
}
+ /* XMP uses datetime in ISO 8601 format */
+ datetime_buf = g_date_time_format (datetime, "%Y:%m:%dT%T\%:z");
+
+ gexiv2_metadata_try_set_tag_string (g2metadata,
+ "Xmp.xmp.ModifyDate",
+ datetime_buf, &error);
+ if (error)
+ {
+ g_warning ("%s: failed to set metadata '%s': %s\n",
+ G_STRFUNC, "Xmp.xmp.ModifyDate", error->message);
+ g_clear_error (&error);
+ }
+ gexiv2_metadata_try_set_tag_string (g2metadata,
+ "Xmp.xmp.MetadataDate",
+ datetime_buf, &error);
+ if (error)
+ {
+ g_warning ("%s: failed to set metadata '%s': %s\n",
+ G_STRFUNC, "Xmp.xmp.MetadataDate", error->message);
+ g_clear_error (&error);
+ }
+
if (! g_strcmp0 (mime_type, "image/tiff"))
{
/* TIFF specific XMP data */
@@ -217,17 +239,9 @@ gimp_image_metadata_save_prepare (GimpImage *image,
g_clear_error (&error);
}
- g_snprintf (buffer, sizeof (buffer),
- "%d:%02d:%02d %02d:%02d:%02d",
- g_date_time_get_year (datetime),
- g_date_time_get_month (datetime),
- g_date_time_get_day_of_month (datetime),
- g_date_time_get_hour (datetime),
- g_date_time_get_minute (datetime),
- g_date_time_get_second (datetime));
gexiv2_metadata_try_set_tag_string (g2metadata,
"Xmp.tiff.DateTime",
- buffer, &error);
+ datetime_buf, &error);
if (error)
{
g_warning ("%s: failed to set metadata '%s': %s\n",
@@ -242,32 +256,7 @@ gimp_image_metadata_save_prepare (GimpImage *image,
! gexiv2_metadata_has_iptc (g2metadata))
*suggested_flags &= ~GIMP_METADATA_SAVE_IPTC;
- str = g_date_time_format (datetime, "%Y-%m-%d");
- gexiv2_metadata_try_set_tag_string (g2metadata,
- "Iptc.Application2.DateCreated",
- str, &error);
- if (error)
- {
- g_warning ("%s: failed to set metadata '%s': %s\n",
- G_STRFUNC, "Iptc.Application2.DateCreated",
- error->message);
- g_clear_error (&error);
- }
- g_free (str);
-
- str = g_date_time_format (datetime, "%H:%M:%S%:z");
- gexiv2_metadata_try_set_tag_string (g2metadata,
- "Iptc.Application2.TimeCreated",
- str, &error);
- if (error)
- {
- g_warning ("%s: failed to set metadata '%s': %s\n",
- G_STRFUNC, "Iptc.Application2.TimeCreated",
- error->message);
- g_clear_error (&error);
- }
- g_free (str);
-
+ g_free (datetime_buf);
g_date_time_unref (datetime);
g_clear_pointer (&comment, g_free);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]