libgimp: fix issue #6050 Phantom comments on pictures.
Since version 0.27.3 exiv2 has changed how it returns comments for Exif.Photo.UserComment. We now get the comment including the charset=Ascii value. Let's remove anything that's not part of the actual comment. To not complicate things we will only handle charset=Ascii for now since I've never seen any other charset used.
This commit is contained in:
@ -37,9 +37,10 @@ typedef struct
|
|||||||
gint type;
|
gint type;
|
||||||
} XmpStructs;
|
} XmpStructs;
|
||||||
|
|
||||||
|
static gchar * gimp_image_metadata_interpret_comment (gchar *comment);
|
||||||
|
|
||||||
static void gimp_image_metadata_rotate (GimpImage *image,
|
static void gimp_image_metadata_rotate (GimpImage *image,
|
||||||
GExiv2Orientation orientation);
|
GExiv2Orientation orientation);
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
@ -80,6 +81,37 @@ gimp_image_metadata_load_prepare (GimpImage *image,
|
|||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
gimp_image_metadata_interpret_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 return NULL 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);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
real_comment = g_strdup (real_comment);
|
||||||
|
g_free (comment);
|
||||||
|
return real_comment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_image_metadata_load_finish:
|
* gimp_image_metadata_load_finish:
|
||||||
* @image: The image
|
* @image: The image
|
||||||
@ -109,6 +141,8 @@ gimp_image_metadata_load_finish (GimpImage *image,
|
|||||||
|
|
||||||
comment = gexiv2_metadata_get_tag_interpreted_string (GEXIV2_METADATA (metadata),
|
comment = gexiv2_metadata_get_tag_interpreted_string (GEXIV2_METADATA (metadata),
|
||||||
"Exif.Photo.UserComment");
|
"Exif.Photo.UserComment");
|
||||||
|
comment = gimp_image_metadata_interpret_comment (comment);
|
||||||
|
|
||||||
if (! comment)
|
if (! comment)
|
||||||
comment = gexiv2_metadata_get_tag_interpreted_string (GEXIV2_METADATA (metadata),
|
comment = gexiv2_metadata_get_tag_interpreted_string (GEXIV2_METADATA (metadata),
|
||||||
"Exif.Image.ImageDescription");
|
"Exif.Image.ImageDescription");
|
||||||
|
Reference in New Issue
Block a user