Picasa face detection to Lightroom

I do most of my photo editing, and picture organizing, in Adobe Photoshop Lightroom. Since I now how over forty thousand pictures from miscellanous events and concerts, and everything else, I like to tag people in pictures, so I can find them again, easily, if anyone asks.

Picasa 3 came with a face detection feature, which scans through all the pictures in your library, and tries to find people with some fancy algorithm. You can then add a name to the face, and easily see all pictures you have with that person in it. Almost. It doesn’t find a face in every situation, so it is not perfect, but it is a good start.

However, Picasa does not store the data about people in the files metadata. You can trick it in there, but since I work with RAW files (NEF), and Picasa doesn’t use XMP for metadata, that is not a good way to do it.

With a bit of reasearch, I found out that in every directory where there are pictures with found faces, Picasa stores a file ( .picasa.ini) that contains information about what picture file contains faces, where in the file there is a face, and what contact that is hooked up to. Picasa also stores an XML file with all the contacts in them.

Using that I wrote a small Perl-script that gets all the contacts out of the XML-file, scans through the current directory for the .picasa.ini file, matches contacts with that, and stores the new data in XML metadata with the file.

Before using the script, you need to change some variables to point to the right contacts file and such. You also need the XML library for Perl, and the Perl Exiftool-library installed.

The script has only been tested in Windows 7, with Cygwin.

The procedure goes as follow:

  1. In Picasa, do the face tagging. Check the picasa website for help on that.
  2. In Lightroom, make sure you select all the pictures you want to update, and write all the metadata to files. That’s from the metadata menu.
  3. Go to the folder you have some pictures with people in it and run the Perl script.
  4. Open Lightroom again, select the pictures, and choose to read metadata from files.

It seems to be working okay now, but I take no responsibility for damages it may do to your pictures if you try it. Make sure you have a backup first!

To run the script recursively I use the command:

 find . -name \.picasa\.ini -execdir ~/scriptlocation/faceextract.pl \;

The script is available on github

5 thoughts on “Picasa face detection to Lightroom

  1. Janne

    Great job!

    This works in both Ubuntu and OS X. Some slight modifications to paths and adding of perl modules.


  2. Elkin

    Thanks for the script. Works on Ubuntu, but once in a while I get this error:

    Use of uninitialized value $new_subject in concatenation (.) or string at /usr/local/bin/faceextract.pl line 73.
    Use of uninitialized value $new_subject in string eq at /usr/local/bin/faceextract.pl line 79.
    Use of uninitialized value $new_subject in string eq at /usr/local/bin/faceextract.pl line 79.
    No value to add or delete in XMP-dc:Subject
    Added to keywords.
    Use of uninitialized value $new_subject in concatenation (.) or string at /usr/local/bin/faceextract.pl line 106.
    Use of uninitialized value $new_subject in concatenation (.) or string at /usr/local/bin/faceextract.pl line 106.
    File written, no changes.

  3. Greger

    Thanks for the comments. I have gotten some bug reports on e-mail as well, I will try to look into it all when I get the time. Currently a bit swamped.

  4. Jan

    Thanks a lot for this skript. Works perfectlly on fedora 16 to sync faces from picasa to bibble 5. I only had to adjust some pathes (and the regexp in line 55 to fit my .xmp-filenames).
    If it’s OK for you I would maybe publish an adopted version of this script on my blog, with refernce to your blog of course.

    1. Greger

      Please do.
      I haven’t used it, or done anything with it for ages, and I am going to move it over to github, so it will be easier to check out, and follow.


Leave a Reply

Your email address will not be published. Required fields are marked *