Migrating Apple Photo Library to Adobe Lightroom

Started by bluesky, January 17, 2025, 10:57:51 PM

Previous topic - Next topic

bluesky

I apologize if this has already been posted elsewhere. I'm not much of a programmer, but I spent a lot of time migrating my entire Apple Photo Library to Adobe Lightroom. I exported unmodified originals with associated IPTC as XMP sidecars. It became a problem with JPG files (not DNG). Lightroom would not import the metadata. Another issue arose with an apparent Apple bug not using the correct GPS specification, resulting in all images being in the Northern and Eastern hemispheres (i.e. New York City became Kyrgyzstan). Apple uses a very limited set of editable metadata: Title, Description (Caption), Keyword, and Location. All I wanted to do was transfer this information. I think I finally came up with a solution using ExifTool, thanks to much help from Phil and searching other posts. I initially asked a question in another thread, but thought I would move it to this general area, so that others may benefit or comment.

Here is a sample .xmp file that Apple Photos exports:

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <exif:GPSLongitude>74.045901499999999</exif:GPSLongitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSHPositioningError>1</exif:GPSHPositioningError>
         <exif:GPSLatitude>40.690794099999998</exif:GPSLatitude>
         <exif:GPSLatitudeRef>N</exif:GPSLatitudeRef>
         <exif:GPSTimeStamp>2020-12-20T23:15:26Z</exif:GPSTimeStamp>
         <dc:title>Statue of Liberty</dc:title>
         <dc:description>What a beautiful day!</dc:description>
         <dc:subject>
            <rdf:Seq>
               <rdf:li>2019 Canada Cruise</rdf:li>
            </rdf:Seq>
         </dc:subject>
         <photoshop:DateCreated>2019-09-27T11:50:54-04:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>

Here is the command that I use to embed the JPGs. I created a folder called "Convert" inside my Pictures folder where I drop the photos. I have it auto delete the originals since I'm already working with a copy. It seems to work perfectly.

exiftool -overwrite_original -tagsfromfile %d%f.xmp -xmp:all '-XMP:GPSLatitude<$xmp:GPSLatitude# $xmp:GPSLatitudeRef' '-XMP:GPSLongitude<$XMP:GPSLongitude# $xmp:GPSLongitudeRef' '-GPSLatitude*<$xmp:GPSLatitude# $xmp:GPSLatitudeRef' '-GPSLongitude*<$XMP:GPSLongitude# $xmp:GPSLongitudeRef' -ext jpg -r /Users/MyName/Pictures/Convert

bluesky

I thought I had this figured out, but if I process files without GPS coordinates, I get a warning message. I assume it still writes the other metadata. I would just like to clean this up with a conditional check. I've been looking at -if and -TAG-= but still confused. Is there a simple way to add to the script I've written:

IF GPSLatitude is NOT EMPTY, then set GPSLatitude to VALUE? Etc. Sorry for being a newbie.

wywh

#2
Quote from: bluesky on January 17, 2025, 10:57:51 PMAnother issue arose with an apparent Apple bug not using the correct GPS specification, resulting in all images being in the Northern and Eastern hemispheres (i.e. New York City became Kyrgyzstan).

Your command seems to work OK but you can fix that flawed .xmp with:

exiftool -P -overwrite_original -ext xmp -XMP-exif:All= -tagsFromFile @ -XMP-exif:All '-XMP-exif:GPSLongitude<${XMP-exif:GPSLongitude#}${XMP-exif:GPSLongitudeRef#}' '-XMP-exif:GPSLatitude<${XMP-exif:GPSLatitude#}${XMP-exif:GPSLatitudeRef#}' .
Then copy .xmp to images with something like:

exiftool -m -overwrite_original -ext jpg -ext heic '-IPTC:CodedCharacterSet=UTF8' -tagsFromFile %d%f.xmp '-AllDates<XMP-photoshop:DateCreated' '-ExifIFD:OffsetTime*<XMP-photoshop:DateCreated' '-XMP-photoshop:DateCreated<XMP-photoshop:DateCreated' '-EXIF:All<XMP-exif:All' '-GPS:GPSLatitudeRef<Composite:GPSLatitudeRef' '-GPS:GPSLongitudeRef<Composite:GPSLongitudeRef' '-XMP:All<XMP:All' --XMP-exif:GPSDateTime '-IPTC:ObjectName<XMP-dc:Title' '-IPTC:Caption-Abstract<XMP-dc:Description' '-EXIF:ImageDescription<XMP-dc:Description' '-IPTC:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
Use the latest exiftool. In the above to both XMP and IPTC (and IFD0:ImageDescription), File dates use XMP-photoshop offset so they might be off for your computer's location so fix them later, if needed. Photos.app inserts current XMP-exif:GPSDateTime when a location was edited but --XMP-exif:GPSDateTime ignores it. If the location was edited in Photos.app, then the old GPSSpeed*, GPSImgDirection*, GPSDestBearing*, GPSHPositioningError, and GPSAltitude tags might be incorrect because .xmp does not include them so original tags are preserved.

-overwrite_original preserves Finder color tags but deletes Finder color labels so use -overwrite_original_in_place if you need to preserve both.

Copy .xmp to movies with:

exiftool -m -overwrite_original -api QuickTimeUTC=1 -ext mp4 -ext m4v -ext mov -tagsFromFile %d%f.xmp '-QuickTime:CreateDate<XMP-photoshop:DateCreated' '-QuickTime:ModifyDate<XMP-photoshop:DateCreated' '-Track*Date<XMP-photoshop:DateCreated' '-Media*Date<XMP-photoshop:DateCreated' '-Keys:CreationDate<XMP-photoshop:DateCreated' '-Keys:GPSCoordinates<$XMP:GPSLatitude#, $XMP:GPSLongitude#' '-Keys:Title<XMP-dc:Title' '-Keys:Description<XMP-dc:Description' '-Keys:Keywords<XMP-dc:Subject' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .
p.s. Your command seems to work with that flawed .xmp without warnings. But after you fix .xmp with the command above it has:

Warning: [minor] Tag 'xmp:GPSLatitudeRef' not defined - ./image.xmp
...obviously because the flawed .xmp is:

[XMP-exif]      GPSLatitude                     : 40 deg 41' 26.86" N
[XMP-exif]      GPSLatitudeRef                  : N
[XMP-exif]      GPSLongitude                    : 74 deg 2' 45.25" E
[XMP-exif]      GPSLongitudeRef                 : W

...but the fixed is with no references:

[XMP-exif]      GPSLatitude                     : 40 deg 41' 26.86" N
[XMP-exif]      GPSLongitude                    : 74 deg 2' 45.25" W

- Matti


bluesky

Matti, thanks! That's a clever way of correcting the xmp file. However, I want to do a batch run on hundreds of photos. Some of the xmp files have GPS and some do not. If I run your first code, the files without GPS give me an error:

Warning: [minor] Tag 'XMP-exif:GPSLongitude' not defined

During the batch run, I want to check each file to see if Tag XMP-exif:GPSLongitude exists, and if so make the change. I'm still trying to learn conditional syntax and having trouble finding it in the documentation. I would appreciate any help.

Phil Harvey

Add this to the command to process only the files you wanted:

-if '$XMP-exif:GPSLongitude'

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

wywh

Quote from: bluesky on January 18, 2025, 12:15:37 PMSome of the xmp files have GPS and some do not. If I run your first code, the files without GPS give me an error

It seems you get those warnings if you try to copy a non-existent tag from the .xmp. For example, that fixed .xmp no longer has non-standard 'xmp:GPSLatitudeRef' that your command tries to copy (see my previous post). And if the .xmp from Photos.app has no location info you get a warning about missing 'XMP-exif:GPSLatitude' (of course also GPSLongitude etc are missing but they are later in the command so they are omitted at least from that command's warning). That is only a warning so all other tag copies succeed if they exist in the source .xmp.

You asked about conditionals. For example, if you want to update location only to images that already do have a (GPS or XMP) location, your command with that unfixed .xmp would be:

exiftool -if '$GPSLatitude' -overwrite_original -tagsfromfile %d%f.xmp -xmp:all '-XMP:GPSLatitude<$xmp:GPSLatitude# $xmp:GPSLatitudeRef' '-XMP:GPSLongitude<$XMP:GPSLongitude# $xmp:GPSLongitudeRef' '-GPSLatitude*<$xmp:GPSLatitude# $xmp:GPSLatitudeRef' '-GPSLongitude*<$XMP:GPSLongitude# $xmp:GPSLongitudeRef' -ext jpg .
And if you want to add location to only images that do not have a location, your command with that unfixed .xmp would be as below. If the corresponding .xmp does not have a location, you get that warning you can ignore.

exiftool -if 'not $GPSLatitude' -overwrite_original -tagsfromfile %d%f.xmp -xmp:all '-XMP:GPSLatitude<$xmp:GPSLatitude# $xmp:GPSLatitudeRef' '-XMP:GPSLongitude<$XMP:GPSLongitude# $xmp:GPSLongitudeRef' '-GPSLatitude*<$xmp:GPSLatitude# $xmp:GPSLatitudeRef' '-GPSLongitude*<$XMP:GPSLongitude# $xmp:GPSLongitudeRef' -ext jpg .
I now prefer to fix those Photos.app .xmp files so .xmp GPS can be copied correctly with no extra gimmicks.

- Matti