Tags from RegionName

Started by irinaonline, October 12, 2019, 02:00:04 AM

Previous topic - Next topic

irinaonline

1. How is it possible to scan a picture for regionnames and add the first word from the regionname as an iptc keyword (the first word is separated by a space)? And to furthermore examine this first word and if it ends with a number to split it and add the non-numeric part as a second iptc keyword. Explanation: this would simplify the creation of a parent and a child tag.

2. If no regionnames are found I would like to add the tag FACES0 and if regionnames are found I would like to add the tag FACES+<Amount of found faces>.

In how few exiftool commands could this be packed?

Thanks in advance!

Phil Harvey

This may be done in a single command:

exiftool -imagedescription=FACES0 "-keywords<${regionname@;s/(\d+)/, $1/}" -sep ", " "-imagedescription<FACES+${regionname;$_=(()=/, /g)+1}" FILE

Here I have assumed that you want to write ImageDescription with your FACES# tag, but you can change this to whatever tag you want.  Also, this will overwrite existing keywords if there are any regionnames.  Change "<" to "+<" when writing keywords to add to existing keywords.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

Thank you for your help.

The face counting works great, however not for FACE0.

And could you also please look into the first point? A regionname is for example "CLIENT10 Joe Doe". I would like to create 2 keywords from the first word of the regionname: CLIENT and CLIENT10. But only if the first word ends with a number.


Phil Harvey

OK.  So when you say "add a tag" you mean "add a keyword" (for "FACES0")?  I'm guessing here.  This will be a bit tricky.  Also, I missed that you only wanted the first word.

I'll work up a new command for you when I get a chance.

So if I understand, you want ""CLIENT10 Joe Doe" to result in keywords "FACES+1", "CLIENT", "CLIENT10" if it is the only regionname in the file?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

If there is no one tagged in the photo ==> regionname is empty ==> 1 keyword to be added: FACES0

If faces are tagged ==> 1 keyword to be added: FACES<Count>

Regionname = "CLIENT10 John Doe (Las Vegas)" ==> 3 keywords to be added: CLIENT, CLIENT10, CLIENT10 John Doe
Regionname = "CLIENT Jane Doe (New York)" ==> 2 keywords to be added: CLIENT, CLIENT Jane Doe
Regionname = "VENDOR18 John (Chicago)" ==>  3 keywords to be added: VENDOR, VENDOR18, VENDOR18 John

Thank you for your time!

Phil Harvey

OK, we're getting closer.  But what do you mean: "if faces are tagged"?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

If a picture is tagged with a face, then the field regionname gets populated with its name.

Phil Harvey

The logic is complex enough now that this is better done with a user-defined tag.

So here you go:

> exiftool -regionname a.jpg
Region Name                     : CLIENT10 John Doe (Las Vegas), CLIENT Jane Doe (New York), VENDOR18 John (Chicago)
> exiftool -config mykeywords.config "-keywords<mykeywords" a.jpg
    1 image files updated
> exiftool -keywords a.jpg
Keywords                        : FACES+3, CLIENT, CLIENT10, CLIENT10 John Doe, CLIENT, CLIENT Jane Doe, VENDOR, VENDOR18, VENDOR18 John
> exiftool a.jpg -regionname=
    1 image files updated
> exiftool -config mykeywords.config "-keywords<mykeywords" a.jpg
    1 image files updated
> exiftool -keywords a.jpg
Keywords                        : FACES0


Attached is the config file that I used.

Note that using your criteria may result in duplicate keywords as in the example above.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

irinaonline

Thanks for your answer, however, it seems, I am not able to get the config file to get loaded.

I call exiftool with the complete path to the command and in my first test assumed, that exiftool will try to load the config file from the same path, it is located ("C:\Users\Leopold\Dropbox\Essentials\exiftool\exiftool.exe -config DynamicTags.config"). It didn't work. Then I added the path also in front of the config file ("C:\Users\Leopold\Dropbox\Essentials\exiftool\exiftool.exe -config C:\Users\Leopold\Dropbox\Essentials\exiftool\DynamicTags.config"). It didn't work as well.

Is there a special syntax, where the path has to be added?


StarGeek

Putting it in the same directory as exiftool should be enough for any recent version of exiftool. The full path should guarantee that it's getting loaded.

What is the exact error output from exiftool?

If it's "Config file not found", then there's a path/name problem. Make sure the filename is correct and not "DynamicTags.config.txt" if you have extensions hidden.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).