XMP structure handling problem

Started by Archive, May 12, 2010, 08:54:45 AM

Previous topic - Next topic

Archive

[Originally posted by anvoit on 2010-02-14 02:42:33.738468-08]

Hi Phil and others,

I'm having problems to understand how to use exiftool together with XMP-MP tag structures.

1) Deleting XMP-MP structures

For example to add a XMP-MP structure, I use these command line options:
Code:
   -xmp-mp:RegionPersonDisplayName+="Bart Simpson" -xmp-mp:RegionRectangle+="0.2, 0.3, 0.1, 0.2"

But now I would like to delete the XMP-MP structure for "Bart Simpson". I know that I can do this with these options:
Code:
   -xmp-mp:RegionPersonDisplayName-="Bart Simpson" -xmp-mp:RegionRectangle-="0.2, 0.3, 0.1, 0.2"

But what I really do need is that I only specify the RegionPersonDisplayName and that by this the whole structure for this person gets deleted. Is this possible?

2) Creating partially filled XMP-MP structures

How can I create a partially filled XMP-MP structure. E.g. MS Live Photo Gallery populates XMP-MP records only having the xmp-mp:RegionRectangle structure element. This means that the software found a face but no face name for it.

So I need to create XMP-MP structures with only xmp-mp:RegionRectangle and without xmp-mp:RegionPersonDisplayName (again I'm using exiftool command line interface).

Thanks a lot in advance for your help.

And Phil, thanks a lot for this great tool, without it I couldn't provide my software AvPicFaceXmpTagger :-)

Andreas

Archive

[Originally posted by exiftool on 2010-02-14 03:56:03.394199-08]

Hi Andreas,

Exiftool is not really designed for dealing with structured information,
so what you want to do is painful and clumsy in exiftool.

1) ExifTool deals with a flattened metadata model which is much simpler
for simple tasks, but with this model it is not possible to delete a
complete structure.  You must delete the elements individually.

2) Creating a structure with only one element is as easy as just
writing this element.  The trick here is that the element will get added
to the first structure in the file which is missing this element (this
is also a problem when adding all elements of a structure), so if
there are partially filled structures missing this element you will
make unintended associations.  If this is a problem, the work-around
is to fill in the missing elements of the existing structures with
dummy values, then add your new element and delete the dummy
values.

Eventually I hope to add features to exiftool to allow better handling
of structures, and have started down this path by adding the
-struct option, but currently this option only applies
to the -json formatted output.

- Phil

Archive

[Originally posted by anvoit on 2010-02-14 08:26:24.525823-08]

Hi Phil,

first of all thanks for your fast reply!

I already feared that your answeres will be like this, I just wanted to be sure that I'm not missing something. But I think it's not necessary to give more motivation that a way for structure handling is needed for exiftool ;-) I really need this feature, as all workarounds, as you said too, are really clumsy and for my task no way to go. I'm glad that you already started to think about it, thanks a lot.

Anyway, I still have some questions about this issue:

1) Let's assume I have 2 XMP-MP structures in the list:
Code:
{ RegionPersonDisplayName="Bart Simpson", RegionRectangle="0.2, 0.2, 0.2, 0.2" }
{ RegionPersonDisplayName="Bart Simpson", RegionRectangle="0.6, 0.6, 0.6, 0.6" }

So what will happen if I issue the command:
Code:
-xmp-mp:RegionPersonDisplayName-="Bart Simpson"

2) And how can I delete the second RegionPersonDisplayName="Bart Simpson" tag, so that the second entry in the list only contains the RegionRectangle tag?

So from what I understand, when adding tags to a structure, the structures are filled up in order. In other words, for all tags to be added, the structure list is searched for the first structure missing that tag. And the structure search always starts from the beginning. Did I get it right?

So what is the current algorithm for tag deletion regarding structures?

Andreas

Archive

[Originally posted by anvoit on 2010-02-14 16:08:38.039799-08]

Hi Phil,

I have currently another problem:

When I issue the following command:
Code:
exiftool_8.10.exe -preserve -ignoreMinorErrors -charset UTF8 -overwrite_original
    -xmp-mp:ALL=
    -xmp-mp:RegionPersonDisplayName+="Woman 1"
    -xmp-mp:RegionRectangle+="0.177734, 0.360677, 0.125, 0.166667"
    -xmp-mp:RegionPersonDisplayName+="__TempFaceName_1"
    -xmp-mp:RegionRectangle+="0.530273, 0.342448, 0.129883, 0.173177"
    -xmp-mp:RegionPersonDisplayName+="Woman 2"
    -xmp-mp:RegionRectangle+="0.4832227, 0.2175937, 0.2198978, 0.3522393"
    -xmp-mp:RegionPersonDisplayName-="__TempFaceName_1"
    Test.jpg

then the "RegionPersonDisplayName" with value "__TempFaceName_1" isn't deleted.

When I do another invocation of exiftool with this command:
Code:
exiftool_8.10.exe -preserve -ignoreMinorErrors -charset UTF8 -overwrite_original
    -xmp-mp:RegionPersonDisplayName-="__TempFaceName_1"
    Test.jpg

then the "RegionPersonDisplayName" with value "__TempFaceName_1" finally is deleted.

What I'm doing wrong here? Is it not possible to do this with only one invocation of exifttol?

I'm kindly ask for your advice...

Thanks a lot,

Andreas

Archive

[Originally posted by exiftool on 2010-02-14 18:32:45.059451-08]

Hi Andreas,

I think you may want to consider a different approach:

To do what you want and have full control over structures,
I recommend a 3-pass strategy:

Pass 1) extract all information in structure format (using
-struct with either the -json or the
-xmlformat output options).

Code:
exiftool -struct -json -regioninfo FILE

Pass 2) process the structures to add/delete the elements
you want, adding dummy elements (with value 'dummy'
for example) if necessary to fill in missing elements,
then write the new structure elements in order, overwriting
the original tags (ie. do NOT use += or -=).

Pass 3) delete 'dummy' entries (only necessary if there
are dummy entries written in pass 2.

- Phil

Archive

[Originally posted by anvoit on 2010-02-15 00:51:18.528774-08]

Hi Phil,

thanks, honestly, I'm already doing what you proposed.

So my last question still remains: do I really need 2 exifttol invocations? One for adding the tags and one for deleting the dummy tags? This cannot be done in one exiftool call?

Andreas

Archive

[Originally posted by exiftool on 2010-02-15 04:54:19.868447-08]

Hi Andreas,

No, you can't add and delete the same tag in one call.

The alternative is to fill in the empty entries with a string that
you can leave in place (say a single space, or a '-' character).
An empty string might be ideal for this, but unfortunately
you can't write an empty string value from the command line
because the syntax would be the same as deleting the tag
(but this can be done via the API).

- Phil

Archive

[Originally posted by anvoit on 2010-02-15 05:42:07.022166-08]

Thanks Phil,

I've finally found a solution: I use the -execute option with two -@ argument files and -common_args. Using this it's only one call to exifttol (I read the XMP data myself in my application, it's quite easy and I don't need the initial exiftool call).

Thanks again for your help!

Andreas

Archive

[Originally posted by exiftool on 2010-02-16 06:39:33.81412-08]

Hi Andreas,

Right.  The -execute option allows multiple exiftool
calls on the same command line.  This avoids the overhead of
loading exiftool more than once, but doesn't reduce the number
of processing passes.

- Phil

Phil Harvey

Note that the ability to read/write structured XMP information was added to ExifTool 8.44 (Jan. 2011), which greatly simplifies the structure manipulations described here.

See the Structured Information page for details.

- 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 ($).