Author Topic: Convert facetags from WLPG to Picasa  (Read 14861 times)

raldo

  • Jr. Member
  • **
  • Posts: 14
Convert facetags from WLPG to Picasa
« on: August 27, 2012, 05:53:31 PM »
I've tagged a whole bunch of photos in WLPG and I'd like to convert the XMP to Picasa.

Any starting hints? Is it even possible

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 9862
    • ExifTool Home Page
Re: Convert facetags from WLPG to Picasa
« Reply #1 on: August 27, 2012, 06:34:44 PM »
Where does Picasa store this information?  I fear that it may be in a .ini file, which would require a bit of Perl scripting to write.

- Phil
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

gcoupe

  • Newbie
  • *
  • Posts: 6
Re: Convert facetags from WLPG to Picasa
« Reply #2 on: August 28, 2012, 09:59:46 AM »
The latest version of Picasa (3.9) uses the proposed Face Region standard of the Metadata Working Group to store XMP metadata into JPEG files. It should also read in the Microsoft Person Tag (which includes Microsoft's face region data) from the metadata created by WLPG.

The trick is to force Picasa to then write out the Face Region data into the JPEG files. I think it can be done by selecting all the thumbnails of a given person under “People” then right click and choose “Move to New Person…” and reselect the same name. Clicking on “Choose” then seems to do the updating of the files and also adds the tags for all other people who have been recognised in the affected photos. See this post for more info: http://gcoupe.wordpress.com/2011/12/10/picasa-versus-windows-live-photo-gallery/

Of course, using ExifTool would be safer - Picasa 3.9 still has bugs, and will strip out Canon Makernotes... But I'll leave that to others more competent than I.
« Last Edit: August 28, 2012, 10:18:08 AM by gcoupe »

raldo

  • Jr. Member
  • **
  • Posts: 14
Re: Convert facetags from WLPG to Picasa
« Reply #3 on: August 28, 2012, 01:12:33 PM »
In recent versions of Picasa, the info is stored in the file as XMP.

I have attached a test file with persons Test, Test2 tagged. I can see this in Geosetter and it seems as if persons are in a comma separated list (Region Name). The region parameters are similarly in comma separated lists.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 9862
    • ExifTool Home Page
Re: Convert facetags from WLPG to Picasa
« Reply #4 on: August 28, 2012, 01:16:40 PM »
It sounds like the easiest solution is to use Picasa if this works.  Otherwise, it should be possible to do this with ExifTool, but would require a bit of effort to create the necessary user-defined tags.

- Phil
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

raldo

  • Jr. Member
  • **
  • Posts: 14
Re: Convert facetags from WLPG to Picasa
« Reply #5 on: August 28, 2012, 01:27:25 PM »
It is not possible to use Picasa (as far as I understand from the Picasa forums). At least in Picasa's current state. The reason is that Picasa sees the WLPG tags but additionally recognizes the same faces. So one has to manually remove all of Picasa's new selections.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 9862
    • ExifTool Home Page
Re: Convert facetags from WLPG to Picasa
« Reply #6 on: August 28, 2012, 01:47:01 PM »
OK then, ExifTool it is.

If you post a (small) image with a couple of faces tagged by WLPG and the same image with the same faces tagged by Picasa I should be able to come up with a user-defined tag that will do this transformation for you.

- Phil
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

raldo

  • Jr. Member
  • **
  • Posts: 14
Re: Convert facetags from WLPG to Picasa
« Reply #7 on: August 28, 2012, 02:13:46 PM »
OK then, ExifTool it is.
Yup.

I'll redo the image I posted previously in WLPG.

raldo

  • Jr. Member
  • **
  • Posts: 14
Re: Convert facetags from WLPG to Picasa
« Reply #8 on: August 28, 2012, 02:53:35 PM »
I have attached an image where the same people are tagged in approximately the same area as they are tagged in the previously posted picasa image.

As far as I understand, the rectangle corners are in normalized coordinates wrt. width and height in both applications.

Thanks!
« Last Edit: August 28, 2012, 03:58:11 PM by raldo »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 9862
    • ExifTool Home Page
Re: Convert facetags from WLPG to Picasa
« Reply #9 on: August 29, 2012, 06:51:05 AM »
Thanks.  Give me a bit of time to work on this.  I'll try to have something within a day or so.

- Phil
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

raldo

  • Jr. Member
  • **
  • Posts: 14
Re: Convert facetags from WLPG to Picasa
« Reply #10 on: August 29, 2012, 05:08:00 PM »
Thanks.  Give me a bit of time to work on this.  I'll try to have something within a day or so.

- Phil

Great!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 9862
    • ExifTool Home Page
Re: Convert facetags from WLPG to Picasa
« Reply #11 on: August 30, 2012, 08:00:29 AM »
OK, here you go.  Attached is the config file to do this conversion.  (See the sample config file for installation instructions.)

With this config file installed, the following command will translate WLPG regions to standard MWG:

exiftool "-regioninfo<myregion" FILE

(where FILE is one or more file and/or directory names)

Here is what the attached config file looks like:

Code: [Select]
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyRegion => {
            Require => {
                0 => 'RegionInfoMP',
                1 => 'ImageWidth',
                2 => 'ImageHeight',
            },
            ValueConv => q{
                my ($rgn, @newRgns);
                foreach $rgn (@{$val[0]{Regions}}) {
                    my @rect = split /\s*,\s*/, $$rgn{Rectangle};
                    my %newRgn = (
                        Area => {
                            X => $rect[0] + $rect[2]/2,
                            Y => $rect[1] + $rect[3]/2,
                            W => $rect[2],
                            H => $rect[3],
                            Unit => 'normalized',
                        },
                        Name => $$rgn{PersonDisplayName},
                        Type => 'Face',
                    );
                    push @newRgns, \%newRgn;
                }
                return {
                    AppliedToDimensions => { W => $val[1], H => $val[2], Unit => 'pixel' },
                    RegionList => \@newRgns,
                };
            },
        },
    },
);
1;  #end

The code in this ValueConv is quite advanced because it deals with XMP structures, which are tricky.

Let me know how this goes.  It looks to me like the region coordinates use the same coordinate system, but they were just different enough to worry me a bit.  Hopefully this works.

- Phil

Edit:  I checked the Microsoft and MWG specifications, and the X/Y position is top/left for WLPG but center for MWG, so a coordinate transformation was necessary after all.  I have fixed the config file accordingly and attached the new version.

Edit2: Removed the -struct option from the command since it is unnecessary when copying tags (although you must use it when just extracting information if you want to see any of the structures).
« Last Edit: August 31, 2012, 07:32:52 AM by Phil Harvey »
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

raldo

  • Jr. Member
  • **
  • Posts: 14
Re: Convert facetags from WLPG to Picasa
« Reply #12 on: August 30, 2012, 05:13:17 PM »
Thanks, I'll experiment with this over the weekend.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 9862
    • ExifTool Home Page
Re: Convert facetags from WLPG to Picasa
« Reply #13 on: December 27, 2012, 09:03:35 AM »
Attached is a config file that defines another tag to do the reverse conversion.  Here are the commands to use with this config file:

1) Convert from MP WLPG regions to MWG regions:

exiftool -config ExifTool_config_convert_regions "-regioninfo<myregion" FILE

2) Convert from MWG to WLPG regions:

exiftool -config ExifTool_config_convert_regions "-regioninfomp<myregionmmp" FILE

You can avoid the -config option in these commands by activating this config file as the default configuration.  See the instructions in the sample config file for details.

In case people are interested, this is the definition of the new user-defined tag to convert from MWG to WLPG regions:

Code: [Select]
        MyRegionMP => {
            Require => 'RegionInfo',
            ValueConv => q{
                my ($rgn, @newRgns);
                foreach $rgn (@{$val[0]{RegionList}}) {
                    my @rect = @{$$rgn{Area}}{'X','Y','W','H'};
                    $rect[0] -= $rect[2]/2;
                    $rect[1] -= $rect[3]/2;
                    push @newRgns, {
                        PersonDisplayName => $$rgn{Name},
                        Rectangle => join(', ', @rect),
                    };
                }
                return { Regions => \@newRgns };
            },
        },

Note that this will only work for rectangular regions.  The MWG specification also allows circles and points, but these are not supported by the Microsoft MP region structure.

- Phil
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

SonnyJim66

  • Newbie
  • *
  • Posts: 2
Re: Convert facetags from WLPG to Picasa
« Reply #14 on: January 02, 2013, 05:54:19 PM »
Thanks for providing this.  I downloaded the config file and renamed it to make it my default config.

Conversion from Windows Photo Gallery to MWG tags seems to work fine, but each time I try to convert a file with people tags created by Picasa, I get an error message:

Warning: No writable tags set from MWG.jpg

I used Picasa 3.9.0 (Build 136.09.0) on Windows 7 SP1 (64-bit) to tag the faces, and I'm using the following syntax to perform the update:

exiftool "-regioninfomp<myregionmmp" MWG.jpg

Any ideas what I might be doing wrong?

Thanks.