libgimpbase: issue #1561 update Exif.Photo.PixelX/YDimension

Some images have Exif.Photo.PixelXDimension and Exif.Photo.PixelYDimension
metadata tags in addition to Exif.Image.ImageWidth and
Exif.Image.ImageHeight (mainly tiff images). So far, we were not updating
these optional tags, meaning they could get out-of-sync with the actual
dimensions when resizing and then exporting the image.

Since these tags are non essential, we will only update them if they are
already present.
This commit is contained in:
Jacob Boerema 2023-05-26 12:40:58 -04:00
parent 0532cf31b9
commit 52fb1e93f9
1 changed files with 16 additions and 0 deletions

View File

@ -1461,6 +1461,8 @@ gimp_metadata_set_from_xmp (GimpMetadata *metadata,
* @height: Height in pixels
*
* Sets Exif.Image.ImageWidth and Exif.Image.ImageLength on @metadata.
* If already present, also sets Exif.Photo.PixelXDimension and
* Exif.Photo.PixelYDimension.
*
* Since: 2.10
*/
@ -1476,10 +1478,24 @@ gimp_metadata_set_pixel_size (GimpMetadata *metadata,
g_snprintf (buffer, sizeof (buffer), "%d", width);
gexiv2_metadata_try_set_tag_string (GEXIV2_METADATA (metadata),
"Exif.Image.ImageWidth", buffer, NULL);
if (gexiv2_metadata_try_has_tag (GEXIV2_METADATA (metadata),
"Exif.Photo.PixelXDimension", NULL))
{
gexiv2_metadata_try_set_tag_string (GEXIV2_METADATA (metadata),
"Exif.Photo.PixelXDimension",
buffer, NULL);
}
g_snprintf (buffer, sizeof (buffer), "%d", height);
gexiv2_metadata_try_set_tag_string (GEXIV2_METADATA (metadata),
"Exif.Image.ImageLength", buffer, NULL);
if (gexiv2_metadata_try_has_tag (GEXIV2_METADATA (metadata),
"Exif.Photo.PixelYDimension", NULL))
{
gexiv2_metadata_try_set_tag_string (GEXIV2_METADATA (metadata),
"Exif.Photo.PixelYDimension",
buffer, NULL);
}
}
/**