Fix #381: Feature-Request: Make JPEG comment available for overlays
authorAlexander Antimonov <>
Mon, 29 May 2017 11:06:13 +0000 (12:06 +0100)
committerColin Clark <colin.clark@cclark.uk>
Mon, 29 May 2017 11:08:49 +0000 (12:08 +0100)
https://github.com/BestImageViewer/geeqie/issues/381

Additional tag "imagecomment" for JPEG comments

doc/docbook/GuideOptionsWindow.xml
src/exif.c
src/exif.h
src/exiv2.cc
src/image-overlay.c

index 2cee13d..cfcf70f 100644 (file)
           </row>\r
           <row>\r
             <entry>comment</entry>\r
-            <entry>Image comment from metadata</entry>\r
+            <entry>Image comment from XMP metadata</entry>\r
+          </row>\r
+          <row>\r
+            <entry>imagecomment</entry>\r
+            <entry>JPEG image comment</entry>\r
           </row>\r
           <row>\r
             <entry>&lt;meta_tag&gt;</entry>\r
index 0478466..872b9cc 100644 (file)
@@ -1105,6 +1105,18 @@ guchar *exif_get_color_profile(ExifData *exif, guint *data_len)
 }
 
 
+gchar* exif_get_image_comment(FileData* fd)
+{
+       log_printf("%s", _("Can't get image comment: not compiled with Exiv2.\n"));
+       return g_strdup("");
+}
+
+void exif_set_image_comment(FileData* fd, const gchar* comment)
+{
+       log_printf("%s", _("Can't set image comment: not compiled with Exiv2.\n"));
+}
+
+
 /*
  *-------------------------------------------------------------------
  * misc
index 804b805..06dec25 100644 (file)
@@ -158,6 +158,10 @@ void exif_add_jpeg_color_profile(ExifData *exif, guchar *cp_data, guint cp_lengt
 
 gboolean exif_jpeg_parse_color(ExifData *exif, guchar *data, guint size);
 
+/* support for so called "jpeg comment" */
+gchar* exif_get_image_comment(FileData* fd);
+void exif_set_image_comment(FileData* fd, const gchar* comment);
+
 /*raw support */
 guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, gint requested_height);
 void exif_free_preview(guchar *buf);
index 49b8e07..0ad5c61 100644 (file)
@@ -158,6 +158,10 @@ struct _ExifData
        virtual void add_jpeg_color_profile(unsigned char *cp_data, guint cp_length) = 0;
 
        virtual guchar *get_jpeg_color_profile(guint *data_len) = 0;
+
+       virtual std::string image_comment() const = 0;
+
+       virtual void set_image_comment(const std::string& comment) = 0;
 };
 
 // This allows read-only access to the original metadata
@@ -280,6 +284,17 @@ public:
                }
                return NULL;
        }
+
+       virtual std::string image_comment() const
+       {
+               return image_.get() ? image_->comment() : "";
+       }
+
+       virtual void set_image_comment(const std::string& comment)
+       {
+               if (image_.get())
+                       image_->setComment(comment);
+       }
 };
 
 extern "C" {
@@ -415,6 +430,16 @@ public:
        {
                return imageData_->get_jpeg_color_profile(data_len);
        }
+
+       virtual std::string image_comment() const
+       {
+               return imageData_->image_comment();
+       }
+
+       virtual void set_image_comment(const std::string& comment)
+       {
+               imageData_->set_image_comment(comment);
+       }
 };
 
 
@@ -1133,6 +1158,23 @@ guchar *exif_get_color_profile(ExifData *exif, guint *data_len)
        return ret;
 }
 
+gchar* exif_get_image_comment(FileData* fd)
+{
+       if (!fd || !fd->exif)
+               return g_strdup("");
+
+       return g_strdup(fd->exif->image_comment().c_str());
+}
+
+void exif_set_image_comment(FileData* fd, const gchar* comment)
+{
+       if (!fd || !fd->exif)
+               return;
+
+       fd->exif->set_image_comment(comment ? comment : "");
+}
+
+
 #if EXIV2_TEST_VERSION(0,17,90)
 
 guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, gint requested_height)
index bcc5666..7afe1a4 100644 (file)
@@ -336,6 +336,10 @@ static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *v
                        {
                        data = metadata_read_string(imd->image_fd, COMMENT_KEY, METADATA_PLAIN);
                        }
+               else if (strcmp(name, "imagecomment") == 0)
+                       {
+                       data = exif_get_image_comment(imd->image_fd);
+                       }
 #ifdef HAVE_LUA
                else if (strncmp(name, "lua/", 4) == 0)
                        {