Author Topic: LocationCreated (XMP Bag Reader)  (Read 5901 times)

Offline qprjohn

  • Newcomer
  • *
  • Posts: 13
    • View Profile
LocationCreated (XMP Bag Reader)
« on: May 16, 2014, 09:20:08 AM »
I've started this thread out of desperation. I'm building my own application to read/write metadata to JPEG's.

The following post has been put on several different forums and I have had no replies/comments at all.

I appreciate this is a PM forum, and my question does not relate directly to PM, and would ask if anyone could help me with this problem. I use VB.Net and have a limited understanding of C++.

ORIGINAL POST:-

Can anyone help?
I'm building an application to read/write metadata to jpeg's using bitmap metadata in VB.Net (VS2010). I have successfully been able to produce various xmpnodes using the SETQuery function.

I've been able to produce xmpbag, xmpstruct and xmpseq nodes separately.

My problem is that I can create the "locationcreated" xmp bag reader and within that node I can produce an xmp structure reader within the "bag", however I cannot write the various child nodes on the actual data, IE sublocation, city etc;

I have used the following code to successfully produce the xmp bag reader (The IPTC4Ext is a constant that holds the namespace
Public Const IPTC4Ext As String = "/xmp/{wstr=http://iptc.org/std/Iptc4xmpExt/2008-02-29/}:"

My code to successfully produce the xmp bag reader is:-

If metadata.ContainsQuery(IPTC4Ext & "LocationCreated") = False Then
        metadata.SetQuery(IPTC4Ext & "LocationCreated", New BitmapMetadata("xmpbag"))
End If

Next I use the following code to successfully produce an xmp structure reader within the xmp bag reader:-

If metadata.ContainsQuery(IPTC4Ext & "LocationCreated/{ulong=0}") = False Then
       metadata.SetQuery(IPTC4Ext & "LocationCreated/{ulong=0}", New BitmapMetadata("xmpstruct"))
End If

The problem I have is I'm trying to add/modify information in the structure reader pertaining to the location created "children" IE "sublocation" , "city", "state" etc; I have tried different methods including the one shown below to add/modify these values.
metadata.SetQuery(IPTC4Ext & "LocationCreated/{ulong=0}" & IPTC4Ext & "/City", "London")

The xmp bag reader, and xmp structure reader, both appear in the WIC Explorer exactly the same as is produced by Adobe Photoshop and Photomechanic PM5.

Can anyone help me solve this problem?

Regards John

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: LocationCreated (XMP Bag Reader)
« Reply #1 on: May 17, 2014, 06:41:14 AM »
I can't (directly) help you with your problem, but I can make a suggestion, and that is to make use of ExifTool instead of programming all this yourself (been there, done that myself…).

You can either embed ExifTool directly into your program (ExifTool is essentially a Perl library), or, and this is probably the easiest in your case, call the command-line version of ExifTool from your program. Easy and really works like a charm!

Hope this helps,
Hayo
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline qprjohn

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Re: LocationCreated (XMP Bag Reader)
« Reply #2 on: May 17, 2014, 11:39:58 PM »
Hayo

Thanks for your suggestion, I've looked at Exiftool briefly before, as it wasn't written in VB.Net I didn't look long enough to realise it can be used from a command line prompt.

I will look further into this, it looks like a good option, where would be the best place to get information on this?

Again thanks for your suggestion, I'll let you know how I get on.

John

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24763
    • View Profile
    • Camera Bits, Inc.
Re: LocationCreated (XMP Bag Reader)
« Reply #3 on: May 17, 2014, 11:51:34 PM »
Hello John,

In one of your earlier threads, I suggested you execute ExifTool using ShellExecute from your VB.net application:

http://forums.camerabits.com/index.php?topic=9055.msg44067#msg44067
http://forums.camerabits.com/index.php?topic=9055.msg44071#msg44071

ExifTool is written in Perl by Phil Harvey.  You can get it from his website: http://www.sno.phy.queensu.ca/~phil/exiftool/

It is capable of reading and writing EXIF, IPTC, and XMP in a variety of image formats.  You can literally save yourself years of coding time by leveraging ExifTool.  Seriously, find some way to use it instead of reinventing the wheel. ;)

-Kirk

Offline qprjohn

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Re: LocationCreated (XMP Bag Reader)
« Reply #4 on: May 18, 2014, 12:11:56 AM »
Kirk

I should have investigated your suggestion further, looks like I need to spend some time and incorporate this into my app!

Thanks

John

Offline qprjohn

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Re: LocationCreated (XMP Bag Reader)
« Reply #5 on: May 19, 2014, 03:01:30 AM »
I have embedded Exiftool into my app, and I'm using, as suggested the ShellExecute function.

Having tested it reading/writing to basic tags it works well so far.

I should have tried this earlier!

I think the challenge will be reading/writing to structured fields!

Thanks for the suggestions.

Kirk/Hayo if I need any advice with structured fields, are either of you in a position to advise me?

John

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24763
    • View Profile
    • Camera Bits, Inc.
Re: LocationCreated (XMP Bag Reader)
« Reply #6 on: May 19, 2014, 08:18:50 AM »
If you ask questions here, I will do what I can to answer them, as long as they don't require me to do much research to answer your questions in a useful way.

-Kirk

Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: LocationCreated (XMP Bag Reader)
« Reply #7 on: May 19, 2014, 09:40:31 AM »
Hi John,

Sure, I can try to help. What exactly do you mean by structured fields anyway? Do you mean fields that can contain multiple values, e.g., the keywords field? Those fields normally return a comma separated list (or another string if you specify it with the -sep command-line option). When writing you simply use the field assignment (=) multiple times. Adding to an existing list of items is also easy, just use += instead.

Have a look at the manual and especially the examples under "Writing examples".

Hope this helps,
Hayo
Hayo Baan - Photography
Web: www.hayobaan.nl

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24763
    • View Profile
    • Camera Bits, Inc.
Re: LocationCreated (XMP Bag Reader)
« Reply #8 on: May 19, 2014, 10:19:45 AM »
Hayo,

I believe that John is referring to structures like this:

   <Iptc4xmpExt:LocationShown>
    <rdf:Bag>
     <rdf:li
      Iptc4xmpExt:Sublocation="Sublocation 1"
      Iptc4xmpExt:City="City 1"
      Iptc4xmpExt:ProvinceState="State 1"
      Iptc4xmpExt:CountryName="Country 1"
      Iptc4xmpExt:CountryCode="CCode 1"
      Iptc4xmpExt:WorldRegion="World Region 1"/>
     <rdf:li
      Iptc4xmpExt:Sublocation="Sublocation 2"
      Iptc4xmpExt:City="City 2"
      Iptc4xmpExt:ProvinceState="State 2"
      Iptc4xmpExt:CountryName="Country 2"
      Iptc4xmpExt:CountryCode="CCode 2"
      Iptc4xmpExt:WorldRegion="World Region 2"/>
    </rdf:Bag>
   </Iptc4xmpExt:LocationShown>

-Kirk

Offline qprjohn

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Re: LocationCreated (XMP Bag Reader)
« Reply #9 on: May 20, 2014, 07:25:39 AM »
Hi Both

That was exactly the structure I was trying to create in VB.Net.

I'm working through the Exiftool manual and slowly picking up it's methods.

I'll try to keep the questions to a minimum.

Thanks again

John  :)

Offline qprjohn

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Re: LocationCreated (XMP Bag Reader)
« Reply #10 on: May 26, 2014, 08:32:49 AM »
Kirk

I've been using Exiftool as you suggested, another learning curve! (Some of it straight forward, some not!)

It has made producing my app somewhat easier.

Thanks

John