Which software to import Gramps media's information into XMP pictures tags?

I read with interest other posts about importing XMP and Exif tags in Gramps.

I’ve also recently seen a YouTube video about Heredis where the guy after he records a source and includes its picture, he copies the source/citation name he uses in Heredis and pastes it in the comment field of the picture in the Windows file explorer to somehow make them “synchronized”.

I have a lot of named medias or people position described in gramps medias but they aren’t in the pictures XMP fields and I would like to reproduce that in a export/import batch

So I can export a Gramps xml file and easily extract only medias from it, get their name, people position etc… but do you know a software wich could import and create these information into XMP fields of corresponding medias picture ?

(May be that could be an idea to a new gramplet too)

I think it’s a good idea to find a means to get this information out of Gramps and embedded in the image.

How did you get the people position in the export? I chose File | Export then Selected Gramps XML Package (Family Tree with Media). I extracted all the archives and opened the XML file. I looked for an object reference for a photo that I know faces are tagged in gramps. I don’t see any position information.

    <object handle="_e9e4214e4113d024e6eb5f509a3" change="1615229130" id="EBJ-O0655">
      <file src="Families/J/Jackson__Edward_Stephen+Henders__Alicia/Jackson__Edward+Henders__Alicia-Maidstone-England-1922.jpg" mime="image/jpeg" checksum="2808f47ba62c47543a4320a3599875f7" description="Jackson__Edward+Henders__Alicia-Maidstone-England-1922"/>

I also am interested!

Back around the turn of the century, I wanted to label some images on my family site and it seemed that JavaScript was being banned in too many communities. Although the method implemented was browser-friendly & non-threatening CSS, it was far too labor intensive.

Here’s an example:

It required creating a stereo image and using CSS to offset the image’s origin in the picture frame for a hover :

(This site was built as an experiment in learning HTML & CSS. I choose our family genealogy simply because a real world project tends to force you to resolve technical issues … whereas pseudocode or working “textbook assigned problems” allows a learner to sidestep working those issues as “rote”. And I had access to my grandmother’s research that some people wanted to see. For such a “one-time use” case, labor-intensive was livable.)

It seems feasible to generate inline CSS from tagged positions to do something similar: scrolling & zooming the picture frame to each person as the user does a roll-over on the hotlinked name. Or… maybe overlaying an inverse mask if the other method proved too disorienting.

To get the position of a media fragment in the Gramps XML:
The position of persons is in the “objref” tag of the XML, which is in turn in the enclosing object, like “person”. For example:

      <objref hlink="_238CGQ939HG18SS5MG">
       <region corner1_x="51" corner1_y="19" corner2_x="59" corner2_y="33"/>

These numbers are in percent, not pixels.

As far as I know, no-one has created software to copy this information back to a media exiftag. It might be a reasonable tool to create for Gramps, as I don’t think anyone is likely to do it elsewhere.

Here is how I could see a tool external to gramps working and using ExifTool to actually manipulate the image metadata.

  • Parse the Gramps XML document

  • Find all the People > Person > objref that have a Region

    • For each found add the Person._Handle and Objref._hlink (the Reference to a handle) to a structure you can loop through.
  • Loop through the new structure by Object._Handle

    • Parse each image file to get its dimensions.
      exiftool -s -s -ImageWidth -ImageHeight
    • Use the array to loop through each person in the image.
      • Get the Gramps Region definition for each person in the image (from People.person.object.region)
      • Convert region (find the center point and calculate height and width):
        • FROM: corner1_x="30" corner1_y="47" corner2_x="34" corner2_y="54"
        • TO:
                          W = (corner2_x - corner1_x)/100,
                          H = (corner2_y - corner1_y)/100,
                          X = (corner2_x + corner1_x)/2/100,
                          Y = (corner2_y + corner1_y)/2/100,
  • write a JSON document for each Object, containing: (example below)
  • dimensions of image
    • array of people found (name, coordinates)
    • filename: infile-Object_handle.json)
    • execute a command like:
      exiftool "-RegionInfo<=infile-Object_handle.json" objref_filename.jpg

Sample JSON file written for each image - adapted from Structured Information)

  AppliedToDimensions =
     W = 4288,
     H = 2848,
     Unit = pixel,
  RegionList =
      Area =
        W = 0.15, H = 0.17, X = 0.3, Y = 0.4,
        Unit = normalized,
      Description = A Physics Icon {relatively speaking|},
      Name = Albert Einstein,
      Type = Face,
1 Like

On the one hand I understand the wish, on the other hand as stated in a post of mine Utilize media metadata Date and Face-Tags in import and references the preferable way of syncronizing in my opinion would be to have the origin of the faca-tags in the foto and not in the reference of the foto in gramps. If someone would want to go the other way from the reference to the origin in the foto the most conceptually correct way would be to write those tags via a gramplet into the xmp data of the foto directly.
The goal of such syncrozisation in my view would be:

  • have the tag only in ono place
  • the one place holding a tag for a foto should be the foto itself
  • syncronize this information with usage of fotos in gramps
1 Like