[gimp] libgimp: fix timezone in IPTC tag Iptc.Application2.TimeCreated.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: fix timezone in IPTC tag Iptc.Application2.TimeCreated.
- Date: Sun, 15 Nov 2020 01:59:13 +0000 (UTC)
commit 4485296bdc676b9ef5b4142016644d7d8af6e8de
Author: Jehan <jehan girinstud io>
Date: Sun Nov 15 02:44:47 2020 +0100
libgimp: fix timezone in IPTC tag Iptc.Application2.TimeCreated.
Existing implementation was repeating the hours and minutes. This was
obviously not what the format asked. The last hour and minutes are the
ones from the timezone offset. Also rather than playing with snprintf()
and various calls to get each component, let's use g_date_time_format()
which is done exactly for such use case.
It is to be noted that there seems to be a bug in Exiv2 such that the
date and time set through Exiv2 return an error when read back, still
with Exiv2. Read and write use different format. I have reported this
issue, together with a patch (hopefully a good one).
https://dev.exiv2.org/issues/1380
So once this patch (or another) gets merged upstream, the following
warnings (e.g. when reopening a PNG created by GIMP) should disappear:
> ** (file-png:176245): WARNING **: 02:43:25.204: Unsupported date format
> ** (file-png:176245): WARNING **: 02:43:25.204: Unsupported time format
libgimp/gimpimagemetadata-save.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/libgimp/gimpimagemetadata-save.c b/libgimp/gimpimagemetadata-save.c
index a4d65dc0e3..3781d732d6 100644
--- a/libgimp/gimpimagemetadata-save.c
+++ b/libgimp/gimpimagemetadata-save.c
@@ -91,6 +91,7 @@ gimp_image_metadata_save_prepare (GimpImage *image,
gdouble xres;
gdouble yres;
gchar buffer[32];
+ gchar *str;
GExiv2Metadata *g2metadata = GEXIV2_METADATA (metadata);
image_width = gimp_image_width (image);
@@ -184,25 +185,17 @@ gimp_image_metadata_save_prepare (GimpImage *image,
! gexiv2_metadata_has_iptc (g2metadata))
*suggested_flags &= ~GIMP_METADATA_SAVE_IPTC;
- g_snprintf (buffer, sizeof (buffer),
- "%d-%d-%d",
- g_date_time_get_year (datetime),
- g_date_time_get_month (datetime),
- g_date_time_get_day_of_month (datetime));
+ str = g_date_time_format (datetime, "%Y-%m-%d");
gexiv2_metadata_set_tag_string (g2metadata,
"Iptc.Application2.DateCreated",
- buffer);
+ str);
+ g_free (str);
- g_snprintf (buffer, sizeof (buffer),
- "%02d:%02d:%02d-%02d:%02d",
- g_date_time_get_hour (datetime),
- g_date_time_get_minute (datetime),
- g_date_time_get_second (datetime),
- g_date_time_get_hour (datetime),
- g_date_time_get_minute (datetime));
+ str = g_date_time_format (datetime, "%H:%M:%S%:z");
gexiv2_metadata_set_tag_string (g2metadata,
"Iptc.Application2.TimeCreated",
- buffer);
+ str);
+ g_free (str);
g_date_time_unref (datetime);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]