jensb / iphoto2xmp Goto Github PK
View Code? Open in Web Editor NEWExport an Apple iPhoto image library to a new directory (using hardlinks) with all metadata saved in XMP sidecar files.
License: GNU General Public License v3.0
Export an Apple iPhoto image library to a new directory (using hardlinks) with all metadata saved in XMP sidecar files.
License: GNU General Public License v3.0
I've got DEBUG=3; it converts, and at some point I see
...
============W, [2023-09-24T06:49:29.326007 #80827] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
W, [2023-09-24T06:49:29.326055 #80827] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
W, [2023-09-24T06:49:29.326067 #80827] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
================W, [2023-09-24T06:49:46.861895 #80827] WARN -- : malformed GPS degrees: expected [degrees, minutes, seconds]; got [NaN, NaN, NaN]
W, [2023-09-24T06:49:46.861924 #80827] WARN -- : malformed GPS degrees: expected [degrees, minutes, seconds]; got [NaN, NaN, NaN]
W, [2023-09-24T06:49:46.864357 #80827] WARN -- : malformed GPS degrees: expected [degrees, minutes, seconds]; got [NaN, NaN, NaN]
W, [2023-09-24T06:49:46.864383 #80827] WARN -- : malformed GPS degrees: expected [degrees, minutes, seconds]; got [NaN, NaN, NaN]
W, [2023-09-24T06:49:46.882677 #80827] WARN -- : malformed GPS degrees: expected [degrees, minutes, seconds]; got [NaN, NaN, NaN]
W, [2023-09-24T06:49:46.882706 #80827] WARN -- : malformed GPS degrees: expected [degrees, minutes, seconds]; got [NaN, NaN, NaN]
=====W, [2023-09-24T06:49:50.793211 #80827] WARN -- : Badly formed IFD: Infinity
W, [2023-09-24T06:49:50.796622 #80827] WARN -- : Badly formed IFD: Infinity
W, [2023-09-24T06:49:50.797049 #80827] WARN -- : Badly formed IFD: Infinity
===================================================================================================================/Library/Ruby/Gems/2.6.0/gems/exifr-1.4.0/lib/exifr/jpeg.rb:102:in examine': no start of image marker found (EXIFR::MalformedJPEG) from /Library/Ruby/Gems/2.6.0/gems/exifr-1.4.0/lib/exifr/jpeg.rb:34:in
block in initialize'
from /Library/Ruby/Gems/2.6.0/gems/exifr-1.4.0/lib/exifr/jpeg.rb:34:in open' from /Library/Ruby/Gems/2.6.0/gems/exifr-1.4.0/lib/exifr/jpeg.rb:34:in
initialize'
from iphoto2xmp.rb:579:in new' from iphoto2xmp.rb:579:in
block in
each' from iphoto2xmp.rb:438:in
'
It's a bad photo somewhere, right?
Instructions say
sudo apt-get install ruby2.2 ruby2.2-dev libsqlite3-dev
sudo gem2.2 install sqlite3 progressbar CFPropertyList
On Apple OS X High sierra, using Brew to install packages,
it doesn't find packages called ruby2.2-dev or libsqlite3-dev
what is this gem2.2 command - I don't see any executable or shell script by that name
are there instructions for running this on Apple OS X?
Applying the group_modified.sql postmortem causes some albums to loose items. For example an album with 148 items in it, started to show only 4 of them afterwards.
Running sqlite on my ~/Pictures/digikam4.db, and dumping the list of all Images using select * from Images;
, I can see that they are still all there (as expected).
I scanned for one of the missing images in the Images table:
select * from Images where name='104_0436_IMG.JPG';
2273|130|104_0436_IMG.JPG|1|1|2003-01-12T04:33:42|875718|0063e8523c695e070dfc05206ac85a2e
Then I looked for 2273 in the ImageRelations table:
select * from ImageRelations where subject=2273 or object=2273;
2273|2273|1
2273|2273|2
I don't know what this means, or if it helps to debug the problem.
Hello @jensb, I'm the author of osxphotos which as you know performs similar functions (and more) for Photos libraries. osxphotos does not however work with iPhoto libraries. I've been working on a separate but related project (photokit) where I've figured out the private Photos APIs and can now create new Photos libraries, etc. (still pre-alpha but coming along nicely).
With Ventura, Photos no longer will import an iPhoto library which means people using Ventura that have old iPhoto libraries are stuck if they've not been previously converted. I believe that it would be possible to use osxphotos to create a convert-to-photos
tool to convert an iPhoto library to a new Photos library whilst preserving metadata. I'd like to use iphoto2xmp to jump start that work. However, osxphotos is licensed under MIT license and iphoto2xmp is licensed under GPL 3.0. Would you consider allowing me to license derivative works (converting the ruby to python to work osxphotos) under MIT license?
Running iphoto2xmp on High Sierra system, with iPhoto 9.6.1. I try
% ./prepare.py -o /Volumes/LaCie\ scratch\ disk/test/ -v ~/Pictures/iPhoto\ library/
and see this output:
photokam 0.5 - helps you convert your iPhoto 5 image library
Parsing the database...
Opening /Users/mlevin/Pictures/iPhoto library//AlbumData.xml
Building the internal structures
Keywords...
Traceback (most recent call last):
File "./prepare.py", line 259, in
main()
File "./prepare.py", line 46, in main
keywords=data['List of Keywords']
KeyError: 'List of Keywords'
any ideas?
I am trying the code on OSX Yosemite, using its default ruby (sadly it is older than Ruby 2.1 that is mentioned in the source code):
$ ruby --version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
The only requirement that I had to install explicitly was progressbar, which I did with sudo gem install progressbar.
When I try to run the code, I get the following output:
$ ruby iphoto2xmp.rb "/Users/erkcan/Pictures/iPhoto Library" /Users/erkcan/Pictures/DigiKamFamilyLibrary
iphoto2xmp.rb:250:in []': no implicit conversion of String into Integer (TypeError) from iphoto2xmp.rb:250:in
block in
open' from iphoto2xmp.rb:249:in
'
I looked at the code, but I have zero prior experience with Ruby, so could not debug the issue. Any ideas?
Looks like it was checked in mid-debug:
`def link_photo(basedir, outdir, photo, imgfile, origfile)
imgpath = "#{basedir}/#{imgfile}" # source image path, absolute
if photo['rollname']
# FIXME: just for faces debugging
#destpath = "#{outdir}/#{photo['rotation']}/#{File.basename(imgpath)}"
if year = parse_date(photo['roll_min_image_date'], photo['roll_min_image_tz'])
destpath = "#{outdir}/#{year.strftime("%Y")}/#{photo['rollname']}/#{File.basename(imgpath)}"
else
"#{outdir}/#{photo['rollname']}/#{File.basename(imgpath)}"
end
else
"#{outdir}/00_ImagesWithoutEvents/#{imgfile}"
end
#destpath = photo['rollname'] ? "#{outdir}/#{photo['rollname']}/#{File.basename(imgpath)}"
destdir = File.dirname(destpath)
`
The problem is that destpath doesn't always get set. So this error gets thrown:
'dirname': no implicit conversion of nil into String (TypeError)
I see that your code no longer depends on exiftool. But I guess you forgot to remove the exiftool checking part at the beginning of your code.
By the way, thanks a lot for this tool. I am looking for an open-source alternative to iPhoto as I don't want to be left to the whims of Apple's undocumented features. Thanks to your code, I will have a chance to seriously consider moving to digiKam.
I'm trying to follow directions for Ubuntu install:
sudo apt-get install ruby2.2 ruby2.2-dev libsqlite3-dev
I get:
% sudo apt-get install ruby2.2-dev
Reading package lists . . . Done
Building dependency tree
Reading state information . . . Done
E: unable to locate package ruby2.2-dev
E: Couldn't find any package by regex 'ruby2.2·dev'
% sudo apt-get install libsqlite3-dev
Reading package lists." Done
Building dependency tree
Reading state information . . . Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
libsqlite3-dev : Depends: libsqlite3-0 (=3.8.2-1ubuntu2.1) but 3.8.2-1ubuntu2 is to be installed
tinyos-tools : Depends: nescc but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
what am I doing wrong?
Hi, I am trying to merge my pictures database with a database of biological and environmental data from the location of the pics. All I need is to get a spreadsheet with the file name from iPhoto with the keywords and descriptions of the picture. It can can csv, txt.
However, I am getting this message below (I am in MacOs Yosemite). Do you know why it is not creating a new directory?
dyn106-43:Pictures gabzuq$ ruby iphoto2xmp.rb "/exportMetadata" "/Export_here"
iphoto2xmp.rb:37:in mkdir': No such file or directory @ dir_s_mkdir - ~/Export_here (Errno::ENOENT) from iphoto2xmp.rb:37:in
It appears that some photos have incorrect locations entered into their xmp files. Could it be that the code does not clean up the variable that holds the location string after handling each photo and hence photos with no location assigned accidentally get the location data from a previously handled photo?
When converting, I see:
W, [2019-07-07T05:54:32.781197 #35256] WARN -- : Bad date/time value "0000:00:00 00:00:00": mon out of range
is it possible to have it tell me which file has the bad timestamp?
W, [2019-07-07T05:58:24.629657 #35256] WARN -- : Badly formed IFD: Infinity
what does this mean, and how to find out which photo it corresponds to?
When it finished, it said
One or more files were missing from your iPhoto library! See 'missing.log' in output directory.
the missing.log lists a lot of files, but it seems to repeat most of the names again and again. Is that normal, and how to find the "missing" files?
I was able to export my iPhoto library without error, and add it to digikam as a Collection. I see the Tags page, but the tags I see are not a good match to the albums and keywords I had. There are tags here for words that appear in photos' descriptions but are not keywords or albums, and most of my albums/keywords are not in these tags. Is it possible to see (a debug mode?) what keywords and albums it's finding during export?
At first try I failed because I was pointing to directories on different devices. Ran it with i/o in same directory and it worked (noob here, so might be my fault, but it can help others).
Made a mistake on escaping the space of the iphoto directory (noob alert)
More importantly and the reason for me writing this is that there was an error that stopped the process 75% through my 80gb library. I would like to rerun the script but don't know if it appends or overwrites previous work. Not versed on code well enough to check on my own. Thanks.
and I forgot, too bad this awesome effort of yours hasn't made it to the top of google searches on the subject. A lot of painful proccesses on countless blogs involving exiftool and just plain giving up on metadata preservation; thank you for sharing this huge effort.
First, thank you (vielen dank) for the tremendous amount of work you have donated to create the iphoto2xmp script. This has helped many iPhoto users transition to digikam and other photo management systems.
As you know Apple, being the Apple of Steve Jobs and not Steve Wosniak, changes things to suit themselves. The iPhotos database file structure parsed by iphoto2xmp so successfully, does not, and would not be expected to parse the new Apple "Photos" database file structure. As an Apple "Photos" user my brother's family photos are trapped in this new Apple "Photos" database structure which I am trying to help him transfer to digikam running under macOS Catalina.
If by chance you have created a version of iphoto2xmp that parses Apple "Photos" databases it would be wonderful to test that version for you against duplicate and safe to test copies of my brother's PhotoLibraries so that digikam can import his photos and report the results back to you.
I am not a Ruby coder (Assembly, C, C++, shell script), however I might attempt to modify your original iphoto2xmp script to parse the Apple "Photos" database structure, as opensource, with attribution and under the same terms as you posted this fine work.
Thank-you, from mark early in Seattle, NW corner of Vereinigte Staaten
Hi, thanks for putting this up.
My objective is to simply read all the filenames from iPhotos to confirm the sync with a backup storage area and thought your Ruby app would at least start me in the right direction. However, the first problem I am finding is the some of the fields in the RKVersion db do not exist so the Ruby script fails at various points when attempting to run. An example: 'isOriginal' is not there. A similar situation with RKMaster: 'type' does not exist.
I would appreciate any pointers as to what the best approach would be please.
Thanks
ian
Hello!
I found this project while searching Google for a way to export photos from iPhoto. I haven't had a chance to try it yet, but I was just wondering whether your script works for Apple's "Photos" app as well, or just for iPhoto? I took a quick look and Photos appears to use the same database structure as iPhoto. I haven't looked too far into it yet though.
Thanks!
Here is one minor issue (hopefully last). I ran the following postmortem command:
sqlite3 ~/Pictures/digikam4.db < group_modified.sql
and I get the following error:
Error: near line 1: too many terms in compound SELECT
I see that group_modified.sql is quite long; there are close to 5000 lines in it. I guess the problem might be related to the issue with sqlite inserting too many records with a single command. https://stackoverflow.com/questions/10083719/sqlite-issue-when-inserting-large-number-of-records
Would it be possible to break that command into shorter commands?
I assume it's an issue with that image file but I don't know where to start debugging.
3270(2642): IMG_4478.JPG IMG_4478.JPG 0* 83423A…/eH%L8o… taken:20081215-011215-0600 edit:20121124-042419-0600 import:20081215-205653-0600
Orig: 1704x2272 (1.0000/1.0000), Masters/2008/pre Xmas 08/IMG_4478.JPG (found)
=> 0/IMG_4478_v2.JPG
Mod : 1704x2272, Previews/2008/pre Xmas 08/IMG_4478.JPG (found)
=> 0/IMG_4478_v3.JPG
Flip: EXIF 90°/0°, photo 0°, face(s): 0°
GPS : lat: lng:,
AlbumTags: ["TopLevelAlbums/temp/Chrsitmas 2009 Ornament"]
Edit:
... Original Face DB data:
... face: tl: 0.209507 0.745305, wh: 0.449824 0.218310, Garet (1115)
... modface: tl: 0.209507 0.336268, wh: 0.449824 0.599765, Garet (1115)
... After processing:
iphoto2xmp.rb:213:in `block in calc_faces': undefined method `*' for nil:NilClass (NoMethodError)
from iphoto2xmp.rb:197:in `collect'
from iphoto2xmp.rb:197:in `calc_faces'
from iphoto2xmp.rb:757:in `block in <main>'
from iphoto2xmp.rb:414:in `each'
from iphoto2xmp.rb:414:in `<main>'
EVENT: My Photo Stream (thumb: Iub64t+…): 2017-02-11 .. 2017-05-31
129139(62385): IMG_4899.JPG IMG_4899 0* 5%ksiQ…/0r8U7g… taken:20170211-184045-0600 edit:20170212-004045-0600 import:20170212-194625-0600
Orig: 2448x3264 (1.0000/1.0000), Masters/Users/xxxxxxxxx/Library/Application Support/iLifeAssetManagement/assets/sub/01c1c230083779c93adb668e7d090ecb794393e223/IMG_4899.JPG (missing)
Mod : 2448x3264, Previews/Users/xxxxxxxxx/Library/Application Support/iLifeAssetManagement/assets/sub/01c1c230083779c93adb668e7d090ecb794393e223/5%ksiQ89Tsy72VWle3%TjQ/IMG_4899.JPG (missing)
Flip: EXIF °/°, photo 0°, face(s): 0°
GPS : lat: lng:,
iphoto2xmp.rb:606:in `block (2 levels) in <main>': undefined method `[]' for nil:NilClass (NoMethodError)
from iphoto2xmp.rb:604:in `each'
from iphoto2xmp.rb:604:in `inject'
from iphoto2xmp.rb:604:in `block in <main>'
from iphoto2xmp.rb:418:in `each'
from iphoto2xmp.rb:418:in `<main>'
Excellent, I seem to have managed to get my library ported into digiKam.
I now face a minor issue with the postmortem instructions. If the various event data or metadata etc contain single quote characters, the SQL code produced by iphoto2xmp is broken. Let me give an example:
UPDATE Albums SET date='2007-12-16', icon=(SELECT i.id FROM Images i LEFT JOIN Albums a ON i.album=a.id
LEFT JOIN ImageComments c ON c.imageid=i.id WHERE c.comment='Photo 4' AND a.relativePath LIKE '%/Erkcan's book' LIMIT 1) WHERE relativePath LIKE '%/Erkcan's book';
Could it be possible to check the metadata strings for these characters and escape them while preparing the SQL commands?
Once I actually get it to work, what's next - how do I bring the content into DigiKam? It's working a little bit for me (creating some files/directories, before it quits with an error); looking forward to the day it finishes the run, what do I do with the resulting .sql files and the directory - how to import to DigiKam?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.