Author Topic: Read image file plus sidecar?  (Read 1583 times)

dd-b

  • Jr. Member
  • **
  • Posts: 10
Read image file plus sidecar?
« on: June 01, 2017, 12:03:36 AM »
A common idiom I've encountered is having some metadata in the image file, and additional metadata in a sidecar file, related by a similar name (most commonly "foo.tif" and "foo.xmp") in the same directory.  I think this is pretty common.  I know Photo Mechanic will produce such pairs when it feels it can't safely write into the image file (it seems to be less aggressive than exiftool about writing into camera-raw files, in particular).

Not everything present in the image file is written into the xmp file, in the cases I have examined.

How do I read this info, considered as information about *one* photo?  What makes sense in my head (and I'm not a metadata expert, so it may not make sense in the real world) is to read metadata from *both* files together (I'm thinking using the perl library more than the exiftool windows app).  Probably have to indicate which file should win in cases when they contained different values for the same field.  Then I would have all the info in one exiftool object and could query it, modify, or whatever.  (Then how do I write it out?  One answer might be to write it into the image file and delete the sidecar file at that point.)

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16687
    • ExifTool Home Page
Re: Read image file plus sidecar?
« Reply #1 on: June 01, 2017, 07:16:09 AM »
ExifTool treats files individually, but you can draw metadata from multiple files when copying.  The question is, what do you want to do with the metadata?

And when writing, you must write the tags you want to each of the files separately.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

dd-b

  • Jr. Member
  • **
  • Posts: 10
Re: Read image file plus sidecar?
« Reply #2 on: June 01, 2017, 01:47:52 PM »
Still working out the details.  Broadly, I have a large number of image files, which I have tried to put suitable metadata into using a range of tools including Thumbs Plus, Photoshop, Lightroom, Photo Mechanic, Bibble and Aftershot, Irfan View, and no doubt things I'm forgetting.  I find that Thumbs Plus has sometimes put keywords, in particular, only in its database and *not* in the image files. Along the way I also changed my standard for how to tag people (I tried to use "last, first" for years and got in trouble with apps thinking that was two keywords), and there are a certain number of weird "wrong" keywords in the file that are probably human error rather than anything deeply systematic.

I'm "shopping" for tools to use in a hack one-shot application I'm looking to write which will "fix this".  I can read the Thumbs Plus database directly (Access format).  In theory, after fixing all the files, I could then just generate a new Thumbs Plus database, or abandon that application and get my indexing through Lightroom (with some considerable loss of capability).  Fixing the files is the part that's definitely needed, i.e. that is motivating this much work.

Perl is my language of choice for this kind of hack, so the Image::ExifTool library is the obvious choice for reading and writing to the files.  But I haven't used it before so I need to learn enough to make sane choices before I get too committed to any particular plan.  I also have to figure out what the other apps will tolerate, metadata being something of a swamp (as you will know infinitely more clearly than I!).

So, at least for the keywords part of the puzzle, it sounds like my plan should be roughly:  Find the keywords information from each relevant file (image file or files and sidecar files) and in the Thumbs Plus database entry for each of those files.  Purge duplicates.  Make the corrections in keywords for name format, and for broken keywords (this will come out of another DB table I prepare manually saying what if anything to change each "bad" keyword to; it appears to be too ugly to fully automate). Replace keywords in each image file with final set; remove keywords from sidecar file if present. Since I'm transforming the keyword set anyway, I may as well just merge them myself. Then write them to each place I want them. 

I still need to look for *other* information that didn't propagate into the files, so that may become more complicated.

Thank you for the info!  I should be trying to write from perl test scripts today or tomorrow, we shall see.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3785
Re: Read image file plus sidecar?
« Reply #3 on: June 01, 2017, 02:28:31 PM »
(I tried to use "last, first" for years and got in trouble with apps thinking that was two keywords)

I'm guessing Picasa?
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16687
    • ExifTool Home Page
Re: Read image file plus sidecar?
« Reply #4 on: June 01, 2017, 03:40:52 PM »
Well, you've definitely found the right app (er, Perl library) for the job.  The ExifTool part of this should be simple compared to the rest.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

dd-b

  • Jr. Member
  • **
  • Posts: 10
Re: Read image file plus sidecar?
« Reply #5 on: June 01, 2017, 06:05:53 PM »
Well, you've definitely found the right app (er, Perl library) for the job.  The ExifTool part of this should be simple compared to the rest.

I've used the app a *very* little before, to take quick looks at things &c., so I knew about it, and about the underlying Perl library. And I haven't found anything discouraging yet.  So I kinda think my experience in this part may well match your prediction. Which probably won't prevent me from finding things I need help understanding still, though.

dd-b

  • Jr. Member
  • **
  • Posts: 10
Re: Read image file plus sidecar?
« Reply #6 on: June 01, 2017, 06:07:17 PM »

I'm guessing Picasa?

I don't think so. I've done so little with Picasa, and I seem to remember seeing signs of the problem before I first played with it.  But it's old now, so I'm not completely certain.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3785
Re: Read image file plus sidecar?
« Reply #7 on: June 01, 2017, 06:37:05 PM »
I don't think so. I've done so little with Picasa, and I seem to remember seeing signs of the problem before I first played with it.  But it's old now, so I'm not completely certain.

I mentioned it becaus that' is how Picasa deals with keywords with commas in them. Each part is treated as a separate keyword.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.