How do image editors handle metadata? How does GIMP handle metadata?

Hi everyone, I’m a young programming enthusiast and for a few months I’ve been exploring the GIMP repository and studying how images work in computer science. I would like to contribute to the GIMP project one day but at the moment I still have many gaps.

As an exercise I created a mini image editor.
image → decompress → bitmap → image changes → bitmap → compress → image

I think the backbone of all image editors is this but I’m not sure.

At this point I was curious. How do image editors handle metadata? How does GIMP handle metadata?

Thinking about it, two possible scenarios came to mind.

  1. During image decompression GIMP divides the bitmap relating to the actual image from the rest. Now I can make changes to the source image by editing the bitmap. Once the changes have been made, I can compress again the image and fully re-add the block of information that I separated from the bitmap during decompression (modifying some metadata that changed during editing).

In this way all the metadata present in the initial image will also be present in the final one (Some values will have changed based on the changes I made to the image).

  1. During image decompression GIMP divides the bitmap relating to the actual image from the rest. Now I can make changes to the source image by editing the bitmap. Once the changes have been made I can compress again the image but this time the block of information that I separated from the bitmap during decompression is not added in its entirety but the individual metadata that GIMP recognizes in the block of information is added one by one.

This way anything that GIMP doesn’t recognize in the information block is discarded. Anything it recognizes can be copied into the final image instead.

The second scenario seems to me the most plausible for two reasons:

  1. When I export an image with GIMP I can choose whether or not to export the resolution, EXIF data, XMP data, IPTC data…
  2. I did a test, I took 10 jpg images with different metadata, I exported them with GIMP by deselecting everything in the export window and analyzing them with exiftool I noticed that they all have the same metadata.

Can anyone explain better how metadata works in GIMP? Where can I look in the GIMP repository to find this info? Every time I export an image to jpg with GIMP by deselecting all the metadata from the metadata window, will I always have the result a jpg with the same number of metadata, i.e. the fundamental ones?

Thank you. :wink:

GIMP handles metadata through the gexiv2 and exiv2 libraries.

The first places in GIMP code to look for metadata handling is our plug-in interface libgimp, more specific https://gitlab.gnome.org/GNOME/gimp/-/blob/master/libgimp/gimpimagemetadata.c?ref_type=heads and for saving https://gitlab.gnome.org/GNOME/gimp/-/blob/master/libgimp/gimpimagemetadata-save.c?ref_type=heads.

If after exporting to jpeg there is metadata when you deselected that should be reported as a bug (make sure to give all relevant info like GIMP version, OS and a sample image). Note that when you have thumbnail or color profile saving enabled, there will always be a limited amount of exif metadata saved, since those are saved inside the exif metadata.

Thank you! I’ll start studying the two links you sent.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.