6 Replies Latest reply on Jun 17, 2009 1:32 AM by K3k0

    Reading metadata with exiftool

    john beardsworth Adobe Community Professional & MVP

      OK, let's bounce this one around and see if anyone has an elegant solution!


      I'd like to read metadata that is in images/sidecars, but which LR doesn't display, and put the information into custom fields. While it would be great to have direct access - ie the SDK should let you read XMP data from files or from the Additional_metadata SQL table - in in its absence I am using Exiftool to extract that information. Where I hit a roadblock is that LRTasks can send the correct command line, but LRTasks.execute only returns a 0 or 1, the OS exit message, and not the Exiftool string.


      So I'm forced to look at alternatives. One would be to make Exiftool generate a temporary file, and then attempt to read that. Any other ideas - or support for the above feature request ?



        • 1. Re: Reading metadata with exiftool
          DFBurns Level 1

          John - What you're asking for has been on my to-do list for a long time. I had the exact same problem - needing to read the stdout of an external app - and the code I expected to write was going to do just what you describe with writing a temp file then reading it. I simply haven't gotten around to coding it up yet. I would definitely support this as feature request.



          • 2. Re: Reading metadata with exiftool
            john beardsworth Adobe Community Professional & MVP

            Thanks Dave - that's good to confirm the approach. It's such a pain to be using Exiftool to do what LR's perfectly-good XMP engine could be made to do!



            • 3. Re: Reading metadata with exiftool
              DawMatt Level 3

              Hi John,


              First of all, I agree that we need more open metadata read/write capabilities in Lightroom SDK.  The current artificial limit is frustrating and if they didn't have the limit in place you wouldn't need to deal with the second issue.


              re Executing a command and returning the output. This would be a good feature to be added to the Lightroom SDK.  I'm envisaging something like the popen function that has been available in C since forever.  The LightroomTether plugin (source is unencrypted) includes a Mac specific example of how popen has been emulated using a FIFO file.  Might be possible to do this on Windows as well but would probably require the user to have their drive formatted using NTFS (to use NTFS streams) so would only work for some Windows users.  In the short term we probably need to use wrapper functions to hide the detail of creating, blocking for program return code, reading temporary files then returning the STDIO and STDERR results, but I'd prefer this to be available in the SDK.



              • 4. Re: Reading metadata with exiftool
                DFBurns Level 1

                Hmmm, I responded via email 8 hours ago yet it hasn't shown up. This response might be duplicated if there's just a big latency:


                John - Yes, it's frustrating knowing how much powerful functionality is sitting there but not accessible to us. I hope the SDK opens up much more in upcoming versions.


                Let me know when/if you proceed with this particular idea. I have a project I'm going to need this for in about a month or so and it'd be nice to not reinvent the wheel. If you won't need it until after that, I'll get it going and then we can compare notes when you're ready. Plus, I'm on Windows and would need a Mac user to verify things are working - I assume you'll need the reverse (?).



                • 5. Re: Reading metadata with exiftool
                  Mark J M Wilson Level 1

                  John, another vote for better XMP support in the LR SDK, along with better access to the keywords...at least be able to set them!


                  In the meantime...earlier this year I started looking at using option -X to format the Exiftool output as XML and piping it to a file, then reading the file and parsing it with LrXml.  I didn't get much beyond testing the theory and pushed the feature further down my todo list...but I am getting close to needing the functionality again.


                  Interested to see if anyone has any more ideas or has anyone already coded it?

                  • 6. Re: Reading metadata with exiftool

                    +1 to better XMP support in SDK.


                    I've done something similar, but as i don't need the Exif info in the program, i have no problem reading it (open notepad and it's done).


                    I guess -X parameter and XML parsing is the best solution and doesn't seem too difficult :-)