[gexiv2/wip/fix-metadata-pixelsize: 1/2] metadata: Fix X/Y mixup
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gexiv2/wip/fix-metadata-pixelsize: 1/2] metadata: Fix X/Y mixup
- Date: Wed, 24 Oct 2018 07:18:04 +0000 (UTC)
commit bde3a816807ad998f80127b8df0263b036fdc732
Author: Jens Georg <mail jensge org>
Date: Tue Oct 23 22:25:47 2018 +0200
metadata: Fix X/Y mixup
Fixes #33
gexiv2/gexiv2-metadata.cpp | 6 +++---
test/gexiv2-regression.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 3 deletions(-)
---
diff --git a/gexiv2/gexiv2-metadata.cpp b/gexiv2/gexiv2-metadata.cpp
index 8823651..98ded9d 100644
--- a/gexiv2/gexiv2-metadata.cpp
+++ b/gexiv2/gexiv2-metadata.cpp
@@ -559,7 +559,7 @@ void gexiv2_metadata_set_metadata_pixel_width (GExiv2Metadata *self, gint width)
exif_data["Exif.Photo.PixelXDimension"] = static_cast<uint32_t>(width);
exif_data["Exif.Image.ImageWidth"] = static_cast<uint32_t>(width);
xmp_data["Xmp.tiff.ImageWidth"] = static_cast<uint32_t>(width);
- xmp_data["Xmp.exif.PixelYDimension"] = static_cast<uint32_t>(width);
+ xmp_data["Xmp.exif.PixelXDimension"] = static_cast<uint32_t>(width);
}
void gexiv2_metadata_set_metadata_pixel_height (GExiv2Metadata *self, gint height) {
@@ -569,10 +569,10 @@ void gexiv2_metadata_set_metadata_pixel_height (GExiv2Metadata *self, gint heigh
Exiv2::ExifData& exif_data = self->priv->image->exifData();
Exiv2::XmpData& xmp_data = self->priv->image->xmpData();
- exif_data ["Exif.Photo.PixelXDimension"] = static_cast<uint32_t>(height);
+ exif_data ["Exif.Photo.PixelYDimension"] = static_cast<uint32_t>(height);
exif_data ["Exif.Image.ImageLength"] = static_cast<uint32_t>(height);
xmp_data ["Xmp.tiff.ImageLength"] = static_cast<uint32_t>(height);
- xmp_data ["Xmp.exif.PixelXDimension"] = static_cast<uint32_t>(height);
+ xmp_data ["Xmp.exif.PixelYDimension"] = static_cast<uint32_t>(height);
}
gchar* gexiv2_metadata_get_comment (GExiv2Metadata *self) {
diff --git a/test/gexiv2-regression.c b/test/gexiv2-regression.c
index 3b174a8..45e22b0 100644
--- a/test/gexiv2-regression.c
+++ b/test/gexiv2-regression.c
@@ -29,6 +29,8 @@ static void test_ggo_31(void)
g_assert_true(result);
gexiv2_metadata_set_metadata_pixel_height(meta, 123);
+ /* Would abort without fix */
+
g_clear_object(&meta);
}
@@ -55,6 +57,55 @@ static void test_ggo_32 (void)
g_clear_object(&meta);
}
+/* Regression test for https://gitlab.gnome.org/GNOME/gexiv2/issues/33 */
+static void test_ggo_33 (void)
+{
+ GExiv2Metadata *meta = NULL;
+ gboolean result = FALSE;
+ GError *error = NULL;
+ glong pixels = 0;
+
+ meta = gexiv2_metadata_new();
+ g_assert_nonnull(meta);
+
+ result = gexiv2_metadata_open_path (meta, SAMPLE_PATH "/no-metadata.jpg", &error);
+ g_assert_no_error(error);
+ g_assert_true(result);
+
+
+ /* Check all the width tags and check that they have the same value */
+ gexiv2_metadata_set_metadata_pixel_width(meta, 1234);
+ pixels = gexiv2_metadata_get_tag_long(meta, "Exif.Photo.PixelXDimension");
+ g_assert_cmpint(pixels, ==, 1234);
+
+ pixels = gexiv2_metadata_get_tag_long(meta, "Exif.Image.ImageWidth");
+ g_assert_cmpint(pixels, ==, 1234);
+
+ pixels = gexiv2_metadata_get_tag_long(meta, "Xmp.tiff.ImageWidth");
+ g_assert_cmpint(pixels, ==, 1234);
+
+ pixels = gexiv2_metadata_get_tag_long(meta, "Xmp.exif.PixelXDimension");
+ g_assert_cmpint(pixels, ==, 1234);
+
+
+ /* Check all the height tags and check that they have the same value */
+ gexiv2_metadata_set_metadata_pixel_height(meta, 4321);
+ pixels = gexiv2_metadata_get_tag_long(meta, "Exif.Photo.PixelYDimension");
+ g_assert_cmpint(pixels, ==, 4321);
+
+ pixels = gexiv2_metadata_get_tag_long(meta, "Exif.Image.ImageLength");
+ g_assert_cmpint(pixels, ==, 4321);
+
+ pixels = gexiv2_metadata_get_tag_long(meta, "Xmp.tiff.ImageLength");
+ g_assert_cmpint(pixels, ==, 4321);
+
+ pixels = gexiv2_metadata_get_tag_long(meta, "Xmp.exif.PixelYDimension");
+ g_assert_cmpint(pixels, ==, 4321);
+
+ g_clear_object(&meta);
+}
+
+
static void test_bgo_792239(void)
{
GExiv2Metadata *meta = NULL;
@@ -158,6 +209,7 @@ int main(int argc, char *argv[static argc + 1])
g_test_add_func("/bugs/gnome/790925", test_bgo_790925);
g_test_add_func("/bugs/gnome/gitlab/31", test_ggo_31);
g_test_add_func("/bugs/gnome/gitlab/32", test_ggo_32);
+ g_test_add_func("/bugs/gnome/gitlab/33", test_ggo_33);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]