Writing to "artworkorobject" structure using VB.Net

Started by QPRJohn, September 11, 2014, 07:50:57 AM

Previous topic - Next topic

QPRJohn

With some previous help from Phil I have been able to read the "artworkorobject" structure and display the various values in a data-grid view.

I am aware that when using the command line arguments with Windows, tag values require quotation marks around the tag value EG " -AuthorsPosition="JEC".

I'm trying to write the artworkorobject structure argument to send to Exiftool, I have run into several interesting problems I need help with.

An example of the structure as retrieved using the -struct command:-
{AOCopyrightNotice=CNO 1,AOCreator=[Creator 1],AODateCreated=2014:01:01,AOSource=Source 1,AOSourceInvNo=SIN 1,AOTitle=Title 1}]

When I attempt to write it back using the following code (note the "" marks added to the tag values) -

-artworkorobject="[{AOCopyrightNotice="CNO 2",AOCreator="[Creator 2]",AODateCreated="2014:01:02",AOSource="Source 2",AOSourceInvNo="SIN 2",AOTitle="Title 2"},{AOCopyrightNotice="CNO 1",AOCreator="[Creator 1]",AODateCreated="2014:01:01",AOSource="Source 1",AOSourceInvNo="SIN 1",AOTitle="Title 1"}]

All this will record is "CNO" up to the first space in the code, I assume that Exiftool sees this as the point to start a new command line. I get the following errors back from Exiftool-
Warning: Missing closing brace for structure
Error: File not found - 2,AOCreator=[Creator
Error: File not found - 2],AODateCreated=2014:01:02,AOSource=Source
Error: File not found - 2,AOSourceInvNo=SIN
Error: File not found - 2,AOTitle=Title
Error: File not found - 2},{AOCopyrightNotice=CNO
Error: File not found - 1,AOCreator=[Creator
Error: File not found - 1],AODateCreated=2014:01:01,AOSource=Source
Error: File not found - 1,AOSourceInvNo=SIN
Error: File not found - 1,AOTitle=Title
Error: File not found - 1}] -CreatorAddress="

Each error line at the next space in my code.

I tried

" -artworkorobject=""[{AOCopyrightNotice=CNO 2}]"

and

" -artworkorobject=""[{AOTitle=Title 1}]"

Both successfully recorded the corresponding value with their spacing. Note that I have omitted the quotation marks normally required in my code.

When I try

" -artworkorobject=""[{AOCopyrightNotice=CNO 2,AOTitle=Title 1}]"

I get the following error - Warning: Improperly formed structure for XMP-iptcExt:ArtworkOrObject

This records nothing at all.

I've tried adding more quotation marks in various combinations without success.

Can anyone help me with is?

Should anyone want to see or try my code for reading the structure I'm happy to share it.

John







Phil Harvey

Hi John,

Quote from: QPRJohn on September 11, 2014, 07:50:57 AM
An example of the structure as retrieved using the -struct command:-
{AOCopyrightNotice=CNO 1,AOCreator=[Creator 1],AODateCreated=2014:01:01,AOSource=Source 1,AOSourceInvNo=SIN 1,AOTitle=Title 1}]

This is missing an opening square bracket.  But to write it is as simple as:

exiftool -artworkorobject="[{AOCopyrightNotice=CNO 1,AOCreator=[Creator 1],AODateCreated=2014:01:01,AOSource=Source 1,AOSourceInvNo=SIN 1,AOTitle=Title 1}]" FILE

You may also omit the outside square brackets to write individual structures.

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

QPRJohn

Hi Phil

Thanks for the quick reply.

The first line of code you have reffered to was what I retrieved from Exiftool when reading the structure from a file. I have noticed that I didn't copy the opening [.

I've just tried the following argument: -

  -artworkorobject="[{AOCopyrightNotice=CNO 2,AOCreator=[Creator 2],AODateCreated=2014:01:02,AOSource=Source 2,AOSourceInvNo=SIN 2,AOTitle=Title 2}]

I get - Warning: Improperly formed structure for XMP-iptcExt:ArtworkOrObject

Changing it to

-artworkorobject="[{AOCopyrightNotice=CNO 2,AOCreator=[Creator 2],AODateCreated=2014:01:02,AOSource=Source 2,AOSourceInvNo=SIN 2,AOTitle=Title 2}]"

I get Warning: Improperly formed structure for XMP-iptcExt:ArtworkOrObject

When I tried


" -artworkorobject=""[{AOCopyrightNotice=CNO 2}]"


and


" -artworkorobject=""[{AOTitle=Title 1}]"


Both successfully recorded the corresponding value with their spacing. Note that I have omitted the quotation marks normally required in my code.


When I combine them

" -artworkorobject=""[{AOCopyrightNotice=CNO 2,AOTitle=Title 1}]"

I get Warning: Improperly formed structure for XMP-iptcExt:ArtworkOrObject

I'm in the can't see the wood from the trees syndrome at the moment, so apologies if I've missed something obvious.


John

Phil Harvey

Try these commands exactly:

> exiftool -ver
9.70

> exiftool -artworkorobject="[{AOCopyrightNotice=CNO 2,AOCreator=[Creator 2],AODateCreated=2014:01:02,AOSource=Source 2,AOSourceInvNo=SIN 2,AOTitle=Title 2}]" a.xmp
    1 image files updated

> exiftool -artworkorobject -struct a.xmp
Artwork Or Object               : [{AOCopyrightNotice=CNO 2,AOCreator=[Creator 2],AODateCreated=2014:01:02,AOSource=Source 2,AOSourceInvNo=SIN 2,AOTitle=Title 2}]


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

QPRJohn

Still can't get it working, what I can't understand is if I use:-
" -artworkorobject=""[{AOCopyrightNotice=CNO 2}]"

or

" -artworkorobject=""[{AOTitle=Title 1}]"

it updates the individual tags. But combined as
" -artworkorobject=""[{AOCopyrightNotice=CNO 2,AOTitle=Title 1}]"

doesn't work with the following warning Improperly formed structure for XMP-iptcExt:ArtworkOrObject ??

John

Phil Harvey

Please get this working on the command line first, then figure out the quoting problems that I think you are having in your code.

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

QPRJohn

Hi Phil

Tried your examples on the Command Line, initially the

-artworkorobject="[{AOCopyrightNotice=CNO 2,AOCreator=[Creator 2],AODateCreated=2014:01:02,AOSource=Source 2,AOSourceInvNo=SIN 2,AOTitle=Title 2}]

came up with similar errors I had. By changing it to:-

-artworkorobject=[{AOCopyrightNotice='CNO 2',AOCreator=['Creator 2'],AODateCreated='20140102',AOSource='Source 2',AOSourceInvNo='SIN 2',AOTitle='Title 2'}]

this worked fine.

I've been trying various combinations of quotation marks without success.

Not sure what to do next?

John

Phil Harvey

I don't understand this at all.  Please paste your full command if you can.  What type of shell are you using?  The standard Windows cmd shell uses double quotes, not single.  Also, you are missing a matching double quote in your first argument.

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

QPRJohn

Having not used Exiftool this way before, just to make sure I've done what you asked correctly, I added the argument to the "Exiftool.exe" filename to get

exiftool[( -overwrite_original -artworkorobject=[{AOCopyrightNotice='CNO 2',AOCreator=['Creator 2'],AODateCreated='20140102',AOSource='Source 2',AOSourceInvNo='SIN 2',AOTitle='Title 2'}] -k).exe

I then dragged and dropped an image file onto the .exe. The above worked okay.

I'm off to work now so I'll copy an example of my code later.

I have attached a screen print from Windows Explorer so you can see the Exiftool.exe set up I've used.

Thanks

John

Phil Harvey

Finally the important details are revealed:  You are putting the arguments in the exiftool.exe file name. This is very important information. 

Yes.  In this case the quoting that you gave is correct.

But there is a superfluous opening square bracket immediately after "exiftool" that could be removed.

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

QPRJohn

Glad to say it's sorted now!

I found out why I kept on getting the "Warning: Improperly formed structure for XMP-iptcExt:ArtworkOrObject" I was using my code to send normal tags with "-sep , " in the argument. Having decided to write some code just for the ArtworkOrObject structure I used the code you suggested:-

-overwrite_original  -artworkorobject="[{AOCopyrightNotice=CNO ZZZ,AOCreator=[Creator 1, Creator 2],AODateCreated=2014:01:04,AOSource=Source 8,AOSourceInvNo=SIN 8,AOTitle=Title 8}]" "F:\Football\XMP Test\_ECX4855.JPG"

It worked fine. When I then added the "-sep ," arg it gave me the warning!!

I'm sure had I included the -sep arg in my examples you would have seen it and put me right, sorry for wasting your valuable time!

As I mentioned in my first post I've written some code to break down the structure into to values for each tag, I'm happy to share it if anyone wants to try it out (and probably improve it!). For those interested I'm using VS2010 pro on a Win7 Pro platform.

John

Phil Harvey

Hi John,

Ah, yes.  The -sep option does do bad things to structures.  Maybe this is something that I can fix... I will look into it.

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

Phil Harvey

In the end, after much proverbial chasing of the wild goose, this thread has been useful in uncovering a "feature" of ExifTool that could be improved.  The -sep option should not apply to structured information.  I have fixed this, and ExifTool 9.71 will avoid this problem.

John: Thanks for your perseverance.

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

QPRJohn

Similarly, thanks for your perseverance, glad to help.

John

QPRJohn

Phil

Just loaded V9.72, works a treat now.

Thanks John