Captions, Descriptions, Titles, Picasa and Windows

Started by deb27, July 06, 2015, 04:32:45 PM

Previous topic - Next topic

deb27

I recently discovered that Picasa Captions and Windows file properties do not play well together for JPG files...which is what brought me here.
My goal is to get the captions which I create in Picasa (which are viewable in my online google photo albums) to appear in the Windows File properties Details tab.  Unfortunately Picasa does not always do this for me. 

In my case, my camera has the unfortunate feature in which it writes the text "OLYMPUS DIGITAL CAMERA"  into the Exif:ImageDescription, Xmp:Description and Iptc:Caption-Abstract fields.  And this apparently triggers Picasa to not write the caption to the field(s) that windows uses for "Title" in the file properties.
Anyone wishing to understand the details of that confusing sentence, take a look here:
https://productforums.google.com/d/msg/picasa/GGnwSlb2ULM/LpSaKPT3lNIJ

So...my solution (which I'd love some help with) is as follows:

Write a script which does the following


--First get rid of all the junk that my camera inserted in the fields that I don't want
for each JPG photo in my directory
  if Exif:ImageDescription = "OLYMPUS DIGITAL CAMERA"
    delete this text from the field
  if Xmp:Description = "OLYMPUS DIGITAL CAMERA"
    delete this text from the field
  if Iptc:Caption-Abstract= "OLYMPUS DIGITAL CAMERA"
    delete this text from the field
end loop

--Now that the fields are cleared out (such that future captions created with Picasa will be written properly to the exif),
--go through all the files and put the captions I've already created into the field(s) that windows will display as Title and/or Subject

for each JPG file in the same directory
  if Iptc:Caption-Abstract is not null/empty
    copy the value from Iptc:Caption-Abstract into Exif:ImageDescription
    copy the value from Iptc:Caption-Abstract into Xmp:Description
  end if
end loop


My problem is that while I do have a programming background, I have no experience with Perl. Do I need it?
I am running Windows 7

Many thanks to all of you and incredible gratitude to the creators and supporter of ExifTool and ExifToolGUI without which I'd probably be stuck with a metadata disaster.

Note: in case someone wonders why I am copying Iptc:Caption-Abstract to both Exif:ImageDescription and Xmp:Description it's because, despite numerous test cases, I can't figure out which one Windows uses to populate the Title field. It seems somewhat random. So I just figured I'd do both of them.

Phil Harvey

#1
You don't need programming experience.  ExifTool will do this with two commands:


--First get rid of all the junk that my camera inserted in the fields that I don't want
for each JPG photo in my directory
  if Exif:ImageDescription = "OLYMPUS DIGITAL CAMERA"
    delete this text from the field
  if Xmp:Description = "OLYMPUS DIGITAL CAMERA"
    delete this text from the field
  if Iptc:Caption-Abstract= "OLYMPUS DIGITAL CAMERA"
    delete this text from the field
end loop


exiftool -Exif:ImageDescription-="OLYMPUS DIGITAL CAMERA" -Xmp:Description-="OLYMPUS DIGITAL CAMERA" -Iptc:Caption-Abstract-="OLYMPUS DIGITAL CAMERA" -ext jpg DIR

for each JPG file in the same directory
  if Iptc:Caption-Abstract is not null/empty
    copy the value from Iptc:Caption-Abstract into Exif:ImageDescription
    copy the value from Iptc:Caption-Abstract into Xmp:Description
  end if
end loop


exiftool "-Exif:ImageDescription<Iptc:Caption-Abstract" "-Xmp:Description<Iptc:Caption-Abstract" -ext jpg DIR

- Phil

Edit: Added missing "-"
...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 ($).

StarGeek

Windows file properties don't play well with anything.

I decide to take a few minutes and figure this out, since this info doesn't seem to be documented anywhere from what I can tell.

When you set the Title from Windows Properties, the following tags are set:
  • EXIF:ImageDescription
  • EXIF:XPTitle
  • IPTC:Caption-Abstract
  • XMP:Description
  • XMP:Title

Windows Properties will populate the Title with the same tags, in this order of priority:
  • XMP:Title
  • EXIF:ImageDescription
  • IPTC:Caption-Abstract
  • XMP:Description
  • EXIF:XPTitle

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

deb27

Thanks StarGeek!  I haven't been able to find that info anywhere so I'm glad you documented it.  I'll add to what you wrote:

When you set the Subject field from Windows Explorer -> Properties->Details the following tag is set:

  • EXIF:XPSubject
Windows details will populate the Subject field using the following fields (in priority order)

  • EXIF:XPSubject
  • EXIF:ImageDescription

The Comment field in windows details is apparently simple.
Setting the Comment field sets the tag:

  • EXIF:XPComment
and that is the only field used for displaying the comment

Note: this was tested with Windows 7. Results for other versions of windows may be different.

deb27

Phil, this is totally awesome! Thank you so very much for your response.  I tested it out and i think it solves the problem completely. Note: there is a minor typo in the second command, the dash(-) is missing prior to Xmp. Correct version is:
exiftool "-Exif:ImageDescription<Iptc:Caption-Abstract" "-Xmp:Description<Iptc:Caption-Abstract" -ext jpg DIR

I just have a couple of minor questions.  I got a lot of "Warning: No writable tags are set from <filename>"
I assume that message appears when there is nothing for it to copy?
Is there a way to route the warnings to an output file? I added ">outputfile.txt" in order to capture the output of the command in a file but it doesn't capture the warnings. Is it possible to capture all warnings and errors in the output file too?

What does "Warning: [minor] Error reading PreviewImage from file - <filename>" mean?
How about "Warning: [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto - <filename>

Phil Harvey

#5
Quote from: deb27 on July 06, 2015, 10:25:09 PM
there is a minor typo in the second command, the dash(-) is missing prior to Xmp.

Thanks.  I've edited my original post to fix this.

QuoteI got a lot of "Warning: No writable tags are set from <filename>"
I assume that message appears when there is nothing for it to copy?

Yes.

Is there a way to route the warnings to an output file? [/quote]

Somebody recently asked the same question

QuoteIs it possible to capture all warnings and errors in the output file too?

You can send both stdout and stderr to the same file, like this:  > out.txt 2>&1

QuoteWhat does "Warning: [minor] Error reading PreviewImage from file - <filename>" mean?

Likely the image has been edited and the preview has been removed.

QuoteHow about "Warning: [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto - <filename>

The Microsoft software is extremely buggy.  ExifTool fixes some of their metadata errors when it can.

- Phil

P.S. I've added a sticky post in the Metadata section with the results of your Windows metadata tests.
...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 ($).

deb27

I just tried to run through this process again and now it doesn't work.
I can't get the command which removes the text from the ImageDescription tag to work.

Here's what happens. First, I displayed the values in the tags.  Here's a snippet of that output

D:\pictures\2015\temp>exiftool -a -G1 -s 20150907-Scotland-0025.jpg
[ExifTool]      ExifToolVersion                 : 9.98
[System]        FileName                        : 20150907-Scotland-0025.jpg
[System]        Directory                       : .
[System]        FileSize                        : 1642 kB
[System]        FileModifyDate                  : 2015:09:07 16:36:36-04:00
[System]        FileAccessDate                  : 2015:10:06 22:49:11-04:00
[System]        FileCreateDate                  : 2015:10:06 22:49:11-04:00
[System]        FilePermissions                 : rw-rw-rw-
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[File]          ImageWidth                      : 3200
[File]          ImageHeight                     : 2400
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:2 (2 1)
[IFD0]          ImageDescription                : OLYMPUS DIGITAL CAMERA
[IFD0]          Make                            : OLYMPUS IMAGING CORP.
...


Next I tried to clear out the data that's in the ImageDescription tag. Here's what happened:
D:\pictures\2015\temp>exiftool -Exif:ImageDescription-="OLYMPUS DIGITAL CAMERA" 20150907-Scotland-0025.jpg
    0 image files updated
    1 image files unchanged

Then I tried:

D:\pictures\2015\temp>exiftool -IFD0:ImageDescription-="OLYMPUS DIGITAL CAMERA" 20150907-Scotland-0025.jpg
    0 image files updated
    1 image files unchanged

Since I couldn't get the "-=" to work, I tried to simply delete the data. Like this:

D:\pictures\2015\temp>exiftool -IFD0:ImageDescription="" 20150907-Scotland-0025.jpg
    1 image files updated

Well that deleted the data but I really want the "-=" to work because I don't want to remove the value when it's not equal to "OLYMPUS DIGITAL CAMERA"

Out of curiosity, I wondered if there was some kind of special characters in that string that I couldn't see so I manually reset the tag to contain "OLYMPUS DIGITAL CAMERA" and then tried the "-=" operator to delete it and this time the deletion worked!  See below:
D:\pictures\2015\temp>exiftool -IFD0:ImageDescription="OLYMPUS DIGITAL CAMERA" 20150907-Scotland-0025.jpg
    1 image files updated

D:\pictures\2015\temp>exiftool -IFD0:ImageDescription-="OLYMPUS DIGITAL CAMERA" 20150907-Scotland-0025.jpg
    1 image files updated


So...why didn't the "-=" operator work in the first place? Clearly it wasn't matching the string "OLYMPUS DIGITAL CAMERA" even though I can't see any discrepancies in the text.  I'm still using the same camera that I used the last time I tried this. And I haven't updated the software on my PC. So I have no idea what changed.

I'm baffled. Thanks for any help you can provide.





StarGeek

Try
ExifTool -Exif:ImageDescription-="OLYMPUS DIGITAL CAMERA         " FILEorDIR

Olympus cameras pad the ImageDescription with nine extra spaces.

Edit:   If something doesn't seem to be working right, I'll add the -php option to the command.  It'll often show you parts of the tag that aren't necessarily obvious.  For example, in this case it shows "ImageDescription" => "OLYMPUS DIGITAL CAMERA         "-json option is another choice that may help
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

deb27

Thanks StarGeek.
I used -php as follows:
exiftool -a -G1 -s -php filename.jpg
and got
"IFD0:ImageDescription" => "OLYMPUS DIGITAL CAMERA         ",
So you are definitely correct about the trailing spaces.  Your solution of adding the 9 spaces exiftool -Exif:ImageDescription-="OLYMPUS DIGITAL CAMERA         " filename.jpgto the original command worked great. Thank you very much.

But that leads to another question. Is there any way to make this more robust? I.e. a script that would do the following:
if the ImageDescription tag contains "OLYMPUS" then clear the tag, otherwise leave it alone

Back in July when I wrote the original post, I didn't seem to have the "9 trailing spaces" problem. I have no idea why I have it now. Therefore making the commands (or script) more robust would reduce the possibility that every time I want to fix the tags I have to go figure this out all over again.

Many thanks for the swift reply!!!

Phil Harvey

Quote from: deb27 on October 07, 2015, 11:29:10 AM
Is there any way to make this more robust? I.e. a script that would do the following:
if the ImageDescription tag contains "OLYMPUS" then clear the tag, otherwise leave it alone

There are a few ways to do this:

1) Use the -if option to process only files with the specified condition:

exiftool -if  "$imagedescription =~ /OLYMPUS/" -imagedescription= DIR

(The disadvantage here is that you would have to do your other processing in a separate command.)

2) Create a Composite user-defined tag that returns the value of ImageDescription only if it does not contain "OLYMPUS", then delete the image description and copy this tag back into ImageDescription.

exiftool -config my.config -imagedescription= "-imagedescription<myimagedescription" DIR

(The disadvantage here is that creating and using the config file is a pain.  Also, the file will get rewritten even if nothing needs to be changed.)

3) Do the same thing with the advanced formatting feature:

exiftool -imagedescription= "-imagedescription<${imagedescription;/OLYMPUS/ and $_=undef}" DIR

(No config file needed, but the command line is rather cryptic.)

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

deb27

Got it!  Thank you so very much.  So here's the final summary with the commands I opted to use so that the next poor soul who has to deal with this issue doesn't have to fish it all out of this thread:

First, just for grins, check the value stored within the ImageDescription tag in the jpg files:
exiftool -a -G1 -s -php filename.jpg

Remove "OLYMPUS DIGITAL CAMERA" from ImageDescription, Description and Caption-Abstract
exiftool -if  "$imagedescription =~ /OLYMPUS/" -imagedescription= DIR
exiftool -if  "$Xmp:Description  =~ /OLYMPUS/" -Xmp:Description= DIR
exiftool -if  "$Caption-Abstract =~ /OLYMPUS/" -Caption-Abstract= DIR


If captions had already been created in Picasa, the metadata needs to be updated to put that caption in the proper fields:
exiftool "-Exif:ImageDescription<Iptc:Caption-Abstract" "-Xmp:Description<Iptc:Caption-Abstract" -ext jpg DIR


where DIR is the directory containing the files (or '.' for current directory)

Having done all that, I finally have Picasa captions in the correct fields so that looking at the Windows Properties on the file will show me the Caption in the Title field. Whew!

mphanet

The problem with the solution is that the original files were saved so another step must be done to delete the files.  Wonder if there's an option *not* to save the original files.

Hayo Baan

I think you mean -overwrite_original. With that option, the original file will be overwritten.
Hayo Baan – Photography
Web: www.hayobaan.nl