ExifTool Forum

ExifTool => Developers => Topic started by: QPRJohn on September 11, 2014, 07:50:57 AM

Title: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 11, 2014, 07:50:57 AM
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






Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 11, 2014, 08:12:57 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 11, 2014, 08:44:15 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 11, 2014, 08:49:18 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 11, 2014, 09:50:04 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 11, 2014, 09:52:39 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 11, 2014, 01:08:07 PM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 11, 2014, 01:18:54 PM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 12, 2014, 01:36:14 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 12, 2014, 07:06:16 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 13, 2014, 04:15:04 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 13, 2014, 07:36:57 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: Phil Harvey on September 13, 2014, 08:36:48 AM
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
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on September 14, 2014, 12:16:29 AM
Similarly, thanks for your perseverance, glad to help.

John
Title: Re: Writing to "artworkorobject" structure using VB.Net
Post by: QPRJohn on October 03, 2014, 03:00:04 AM
Phil

Just loaded V9.72, works a treat now.

Thanks John