News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Embed iPhoto metadata in original image file

Started by splinke, November 22, 2013, 01:28:58 AM

Previous topic - Next topic

splinke

After over 20 years on the Mac platform, I have made the difficult decision to switch to Windows for a number of reasons. One issue is migrating my photos and videos out of iPhoto '11 for import into a Windows-compatible photo management program.

I have old photos on which I painstakingly added dates. I chose "Modify original files" when I did that, so I think all of the date metadata already resides in the original file. However, I have also painstakingly added locations, descriptions, and keywords, and it is my understanding that iPhoto stores all of those pieces of information in a separate iPhoto database that does not travel with the original photo files.

I have discovered the abilty to "Export" the photos with the options of exporting "Title and keywords" and "Location information", and that appears to store at least some of the additional metadata in the final file. However, that requires re-compressing the JPEG (with the associated loss of quality), and I have found that the file sizes increase by 2x to 4x.

So, I am looking for a way to embed this additional metadata in the original file without having to re-compress. Is ExifTool capable of doing this? If so, is there a way for non-programmer like me to use it without wreaking havoc?

Phil Harvey

ExifTool does not modify image data, so it doesn't recompress images.  If exporting is the only way to get the metadata out of iPhoto, I suggest doing this then using ExifTool to copy the metadata from the exported images back to the originals.

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

splinke

#2
Thanks for your feedback. I discovered that I can use another Apple program called Aperture to export just the metadata from the files. By default, it appears to create a single tab-delimited file with 40 fields, including the following (the first row of data in the exported file is the 40 field headers):

  • Version Name: This is the filename without the .jpg extension.
  • Keywords: This contains all iPhoto "Keywords" separated by commas.
  • Caption: This contains the iPhoto "Description" which is equivalent to a caption.
  • Latitude: Format is ##,#.########N (N for northern hemisphere)
  • Longitude: Format is ###,##.########W (W for western hemisphere)
Is this something that is compatible with ExifTool, or do you think I will need to export all of the files with embedded metadata. Just to clarify, the metadata from my thousands of photos would all be in this single tab-delimited exported file.

splinke

I also got into an unintended argument with somebody on the iPhoto Apple Discussion Forum. As I stated in my original post here, I expressed concern that, by having to "recompress" the JPEG in order to embed the metadata, iPhoto was actually forcing a very slight lowering in image quality--with the added annoyance that the file size increased by 2x to 4x when choosing "maximum quality". It just seems more logical to directly change the metadata portion of the JPEG file without mucking with the image itself, even though any drop in quality would probably be virtually imperceptible.

One of the people who responded in the forum went off on me several times, stating, for example:
Quote...[T]he original file is not "recompressed". It's a whole new file. The image is put into a new file that has a rather different compression ratio than that created by your camera. That's why you can actually export at a higher jpeg quality than you imported at (and hence a larger file size). The image won't be higher quality, of course, but the file will.

I then tried to clarify by saying that it was my understanding that each time you re-save a JPEG, a lossy JPEG compression routine is run, which can reduce the integrity slightly at each iteration.

He responded:
Quote...You can't "recompress" a file that has never been compressed. That's the key dfference.  You seem quite unable to distinguish between a file and the photo it contains.

The photo is copied to a new file...

If you have not edited the image then exporting as Jpeg in any of the higher quality settings will get you the same image in a less compressed file, with the metadata.

I'll repeat that for you:

The same image, same dimensions, same quality, in a less compressed file.

One more go: the same photo in a different sized box.

iPhoto allows you to export an image into a file that is better quality than your camera does. The same image in a different file...

Am I wrong about JPEGs? If so, I could probably just do a simple export of all of my JPEG files without then trying to write the metadata into the originals. Of course, this would either result in the much larger files, which are bigger to store and stream for viewing, or I would have to select a lower quality than "maximum". iPhoto has "High", "Medium", and "Low" quality while maintaining the same resolution and size, but I am not sure about the specifics. I think "High" produces file sizes approximately the same (or a little smaller) than my current ones.

Phil Harvey

I don't think that this guy knows what he is talking about.  The image data in a JPEG file is compressed using a lossy compression.  If you change the compression factor then you must uncompress and recompress the image, probably introducing more loss.  (Certainly if the compression factor is lower, but I can't say for sure if the compression factor is higher because I don't know if JPEG compression is able to losslessly compress an image that had previously been compressed at a lower quality -- this is possible, but I wouldn't risk it.) There is no separate compression at the file level -- you can't change the size of the "box".

Reading tab-delimited files is not easy, and requires custom scripting.  It would be easier to export the JPEG's and copy the metadata back to the originals like I suggested.

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

Alan Clifford

How about running the tab separated file through "tr" to remove all the commas then running it  through "tr" again to change the tabs to commas?

Phil Harvey

If you can structure the file exactly like the output of the -csv option (every character in the SourceFile column must be exact, and the first row must contain the tag names), then you can import this file with the -csv=CSVFILE feature.

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

splinke

Quote from: Phil Harvey on November 22, 2013, 07:10:51 AM
ExifTool does not modify image data, so it doesn't recompress images.  If exporting is the only way to get the metadata out of iPhoto, I suggest doing this then using ExifTool to copy the metadata from the exported images back to the originals...

OK, I am finally ready to do this project of switching from iPhoto on a Mac to a Windows photo management program. I am trying to figure out what to put on the command line. I apologize for asking for more advice, as this is probably a common request, but I am not adept at command-line stuff.

I have a hierarchical folder tree with a root folder named "destination" on my desktop that contains copies of all of my original unmodified photos that lack all of the metadata I have manually added in iPhoto. I have another hierarchical folder tree with a root folder named "source" on my desktop that contains exported copies of all of my photos into which iPhoto has written as much of the manually added metadata as possible. My goal is copy the new metadata from all of the files in the "source" folder to all of the corresponding files in the "destination" folder.

I have attached ExitTool exports from a typical source and destination file. I believe the most critical entries to copy are:

  • All 5 fields under "IPTC", including Object Name, Caption-Abstract, and Keywords
  • All 4 fields under "GPS"

In the source file, there is also a series of fields added by the iPhoto export under headings starting with "XMP" that are somewhat redundant with other fields. For example, the heading "XMP-xmp" contains "Create Date" and "Modify Date" fields, which are the same as "File Creation Date/Time" and "File Modification Date/Time" under the "System" heading. Another example is the heading "XMP-dc" that contains a "Title" field (same as "Object Name" under the "IPTC" heading) and an "Object" field (same as "Keywords" under the "IPTC" heading). Would it be advantageous to copy these new XMP fields, as well?

Finally, the GPS data also appears to have been redundantly added under the "Composite" heading (in addition to the insertion under the "GPS" heading, as described above). Note that, unlike the IPTC and GPS headings, the Composite heading is already present in the destination file, although it appears that the source file simply adds the new entries, so the entire Composite list of fields could be used to replace the originals, or just the new GPS fields could be added. Again, I am not sure whether this even needs to be done, if the GPS fields are already included under the GPS heading.

There is also a new JFIF heading, Photoshop heading, and a series of ICC-based headings. However, I think those are created when iPhoto is needlessly recompressing the JPEGs while adding the metadata directly to the files. So, I think I should avoid copying all of those.

What command line entry needs to be used to batch copy the relevant metadata for all of the files in the full directory tree?

Also, if anybody has any suggestions on image management software for Windows that will make it easier to handle metadata going forward, I would be very interested.


Phil Harvey

The "Composite" tags you are talking about are derived from the values of other tags, so duplication is expected with these.

The following commands will copy all metadata but JFIF into the same locations in the destination hierarchy.  It won't copy the ICC profile unless you add -icc_profile to the end of the command, and it won't copy the Photoshop information.

cd destination
exiftool -r -P -tagsfromfile source/%d%f.%e -all:all --jfif:all .


Here I have added the -P option to preserve the file modification date/time, although I don't know if this matters to you.  It will modify the file creation date though.

The only trick with this command is setting up the directories so that the -tagsFromFile option will find the corresponding files.  It is easiest to "cd" to the destination so that only relative directories are used in this tree.  When this is done, the "source" directory name can simply be concatenated with the relative destination directory "%d".

Note that you will be left with a bunch of "_original" files in the destination directory when you are done.  You can avoid creating these with the -overwrite_original option, or delete them later with another command and the -delete_original option.

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