Replicate informations from metadata to catalog

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Replicate informations from metadata to catalog

Post by Le_Lion_07 » 08 Jul 14 10:51

Hello from France.

Does anyone know how to change the script (written by Hert for IDi v.5) to replicate from metadata to catalog location information ? I would know what to do to customize this script to replicate from metadata to catalog : "Persons in Image", "Event", "Description", etc.

Would it be possible to obtain a "general purpose" script, with (clearly marked) the parts to change... ?

I am actually talking with a possible future french user of PSU, who already uses an other dam ; so, most of his photos have their own metadata and none of these metadata (except keywords) appears in the catalog structure. With such scripts, he can replicate location information, events, persons, etc.

(Hert's script is available here : http://repository.idimager.com/cgi-bin/ ... df944b6ef7)
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 08 Jul 14 11:24

This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 09 Jul 14 6:51

Hem... I know, your link is the same as the one I give in my message.

My question was : how to modify this script ? I did it for my own use, by deleting the 4e level in location hierarchy (the lowest level, because I don't use it). I looked carefully at the script and founded the solution because there were nothing to look for out of the script, just delete a level and make some other adjustments. But I don't know how to proceed to adapt the script for Event, or Person in Image.

Please, consider the fact : all is simple for someone who knows... and very hard for the rest of the world. In this case, I belong to the rest of the world...
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 09 Jul 14 7:19

The script I sent you is *not* the same. The script was altered to run in Photo Supreme (I'll update the version info in the script), the one you sent doesn't run in Photo Supreme and would not be of any help for your friend, since you explicitly mention that (s)he considers PSU.

To alter the script to store in other categories is explained inside the script. There are also examples there how to use a named category, or how to store under a catalog label instead of a category.

Look in the function DetermineParentContainer to change the parent holder. There, comment out the alternative you want by removing the accolades around that block.

And if you want to create labels based on other metadata then this script can be used for that by altering it. Changing the fields to use is a matter of replacing the XMP fields, once you know which XMP fields to use (see XMP specs for field names).

Here's a sample...

Code: Select all

          // find the country
          AParam := AXmp.FindDesignProperty ('http://ns.adobe.com/photoshop/1.0/', 'photoshop:Country');
          if AParam <> nil then
            AStruct.Add (Nvl(AParam.Content, ''))
          else
            AStruct.Add ('unknown');
/
This is the line to edit:

Code: Select all

          AParam := AXmp.FindDesignProperty ('http://ns.adobe.com/photoshop/1.0/', 'photoshop:Country');
Change 'http://ns.adobe.com/photoshop/1.0/' and 'photoshop:Country' to the XMP values for the field that you want to use.

But maybe best to start at the beginning. What dam is your friend using now? From the questions that you ask I assume that it's iView. Photo Supreme should already import the proprietary People metadata tag that iView creates.
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 09 Jul 14 9:08

I must say that you are right : my friend is using iView. Shame on me, I've forgotten the possibility to import metadata directly from other dam, including iView...

Thank you for your explanations about the script. It certainly will be very useful.
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 09 Jul 14 9:27

Le_Lion_07 wrote:I must say that you are right : my friend is using iView.
That's called experience...every tool has its own quirks and then the questions asked will alway be in that area.
Shame on me, I've forgotten the possibility to import metadata directly from other dam, including iView...
There is the full import in the Data menu. But that has evolved more and more toward the latest MediaPro versions, and I don't know for sure if it also still works for the old iView.

But apart from the import; the quirk in iView is that it writes the come data in undocumented IPTC tags. Not XMP, not Exif, but legacy IPTC. They simply create their own IPTC tags, which are of course not part of the IPTC standard. Photo Supreme will read these tags. I believe they later stopped doing that (pfew) and they started to write their own XMP schema. That is great as XMP allows to be extended.

To make sure that the proprietary info from iView/ExpressionMedia/MediaPro are read to PSU, use the right click on a thumb -> Metadata -> Convert metadata to XMP. Photo Supreme will then do its standard conversion and specifically for iView/EM/MP it will also convert the People from the proprietary metadata to Keywords in dc:Subject.
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 09 Jul 14 20:36

I created a new database with a few photos, just to try the scripts.

The script for location works, no problem, but when I try to replicate people (PersonInImage), nothing happens... :( .

Of course, I've changed :
AParam := AXmp.FindDesignProperty ('http://ns.adobe.com/photoshop/1.0/', 'photoshop:Country');
with :
AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02 ... sonInImage');

There is something wrong... :?:
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 10 Jul 14 13:31

That looks correct to me...

Are you sure that the image that you run this on actually contains the Iptc4xmpExt:PersonInImage field?

If so, can you share your altered script here so I can have a look at it?

Thank you
Hert
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 10 Jul 14 16:28

IDimager wrote:That looks correct to me...

Are you sure that the image that you run this on actually contains the Iptc4xmpExt:PersonInImage field?
Sure.
IDimager wrote: If so, can you share your altered script here so I can have a look at it?
I changed nothing but the lines with XMP properties :
// find the country
AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02 ... sonInImage');
if AParam <> nil then
AStruct.Add (Nvl(AParam.Content, ''))
else
AStruct.Add ('unknown');

// find the state
AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02 ... sonInImage');
if AParam <> nil then
AStruct.Add (Nvl(AParam.Content, ''))
else
AStruct.Add ('unknown');

// find the city
AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02 ... sonInImage');
if AParam <> nil then
AStruct.Add (Nvl(AParam.Content, ''))
else
AStruct.Add ('unknown');

// find the location
AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02 ... sonInImage');
if AParam <> nil then
AStruct.Add (Nvl(AParam.Content, ''))
else
AStruct.Add ('unknown');
I also tried to delete the lines with state, city and location, with no more result :
// find the country
AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02 ... sonInImage');
if AParam <> nil then
AStruct.Add (Nvl(AParam.Content, ''))
else
AStruct.Add ('unknown');
Is there anything else to change in the script ?
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 10 Jul 14 16:39

Thank you. Could you send me a test image by email that I can test this on? Then we'd have identical situations.
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 10 Jul 14 16:57

Done.

Thank you for your help.
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 10 Jul 14 18:52

Thank you for the image.

I overlooked a few things...

1. the XMP property that you want to use is a bag property, meaning it can contain multiple values. The script now assumes that it's a standard variable type.

The question now is what you want the script to do when there are multiple people defined in the bag.

For now, change:

Code: Select all

          // find the people in the image
          AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02-29/','Iptc4xmpExt:PersonInImage');
          if AParam <> nil then
            AStruct.Add (Nvl(AParam.Content, ''))
          else
            AStruct.Add ('unknown');
To

Code: Select all

          // find the people in the image
          AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02-29/','Iptc4xmpExt:PersonInImage');
          if AParam <> nil then
            AStruct.Add (Nvl(AParam.StrContent, ''))
          else
            AStruct.Add ('unknown');
This will work for 1 person in the bag, but won't for multiple...in that case you'd have to iterate over the bag items; something like:

Code: Select all

  procedure HandleItem (AItem: TImageItem);
  var
    ACatItem: TCatalogItem;
    AXmp: TXMP;
    AParam: TMacroParam;
    AStruct: TTntStringList;
    AFound: Boolean;
    i: Integer;
  begin
    ACatItem := TCatalogItem.Create (nil);
    AStruct := TTntStringList.Create;
    try
      // find the image item in the catalog (and only process found items
      if Catalog.FindImageCombined (AItem, ACatItem, False, vptNone) then
      begin
        AXmp := TXMP.Create (nil);
        try
          Catalog.LoadXMPForItem (ACatItem, AXmp, Options.CachedXMP);

          // find the people in the image
          AParam := AXmp.FindDesignProperty ('http://iptc.org/std/Iptc4xmpExt/2008-02-29/','Iptc4xmpExt:PersonInImage');
          if AParam <> nil then
          begin
            for i := 0 to AParam.ArrayContent.Count - 1 do
            begin
              AStruct.Clear;
              AStruct.Add (Nvl(AParam.ArrayContent.Items[i].Content, ''))
              // now we have stored the structure sequentially in the stringlist AStruct
              StoreStructure (ACatItem, AStruct);
            end;
          end;
        finally
          AXmp.Free;
        end;
      end;
    finally
      ACatItem.Free;
      AStruct.Free;
    end;
  end;
2. In the procedure StoreStructure; the first check is that there should be 4 levels. Just delete those lines. The lines to delete are:

Code: Select all

    if AStruct.Count <> 4 then        // the should always be 4 entries
      exit;
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 10 Jul 14 19:34

Thank you, good work ; I was able to replicate people, including several persons in one photo.

But people are assigned inside the category... Places. It would be better if they were inside... People. :wink:
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Hert
Posts: 6142
Joined: 13 Sep 03 7:24

Re: Replicate informations from metadata to catalog

Post by Hert » 11 Jul 14 9:05

Le_Lion_07 wrote:But people are assigned inside the category... Places. It would be better if they were inside... People. :wink:
You can use the first alternative; here it's enabled. Change the name of the category ("People" here) to whatever it's called in your version.

Code: Select all

  function DetermineParentContainer: String;
  var
    ACategory: TCatalogPropCategory;
    AProp: TCatalogItemProp;
  begin
    //result := Catalog.Places.GUID;

    // alternative 1; find a category by name that should contain the places structure
    ACategory := TCatalogPropCategory.Create (nil);
    if Catalog.EnumCategoryNamed ('People', ACategory) then        // enable this line instead of the next on to find a category by name
      result := ACategory.GUID;
    ACategory.Free;

    // alternative 2; find a catalog label by name that should contain the places structure
    {
    AProp := TCatalogItemProp.Create (nil);
    if Catalog.FindPropByName ('North America', AProp, '', True) then        // enable this line instead of the next on to find a category by name
      result := AProp.GUID;
    AProp.Free;
    }
  end;
This is a User-to-User forum which means that users post questions here for other users.
Feature requests, change suggestions, or bugs can be logged in the ticketing system

Le_Lion_07
Posts: 82
Joined: 18 Sep 11 15:19
Location: Annonay, Ardèche, France
Contact:

Re: Replicate informations from metadata to catalog

Post by Le_Lion_07 » 11 Jul 14 10:00

Thank you for your help, it works.

Just two points :
- when a category contains special characters (i.e. : é, è, à, â, etc.), the replication fails. Of course, it is always possible to create a category with no such characters, then to rename it. For instance, create : "Evenements", then once the replication is done, rename it with "Événements" which is the correct word in french. Maybe an issue with the code ? (UTF-8 ?)
- with this line :
if not Catalog.EnumPropName(AParent, AStruct.Strings, AProp, True) then // also search synonyms; you could change that is desired

what to do to disable the research of synonyms ?
Photographies

L'importance du regard...
Tant qu'il y aura des étoiles...

Post Reply