XMP support available?

Bascy

Joined: 2008-06-18
Posts: 5
Posted: Tue, 2008-07-01 19:19

Hi,
i'v seen a few posts about supporting XMP tags in uploaded pics, but these are from years ago.

Is there anything available to have gallery2 use XMP tags that are i.e. put there by Microsoft Live Photo gallery?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2008-07-02 06:01

no, XMP isn't supported yet. i guess you'd need to use some client software to move your XMP data to exif / iptc before uploading the files to g2.

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
Bascy

Joined: 2008-06-18
Posts: 5
Posted: Wed, 2008-07-02 06:25

are there any plans to support this in the future?
Is it on some wishlist maybe?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2008-07-03 05:55

it's on the radar. you can vote for it at http://gallery.menalto.com/sfvote/all (search for XMP).

--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
svillinski

Joined: 2008-07-31
Posts: 5
Posted: Fri, 2008-08-01 16:12

Here's my ExitDescriptionOptions.inc (renamed to .txt) file that I modified to add support for pulling out the Title from Windows Live Photo Gallery. It's a hack, I admit it, but it does the job for me and makes it much easier to add captions to my pictures.

Scott

 
wormie
wormie's picture

Joined: 2003-01-09
Posts: 19
Posted: Fri, 2009-01-02 22:40
svillinski wrote:
Here's my ExitDescriptionOptions.inc (renamed to .txt) file that I modified to add support for pulling out the Title from Windows Live Photo Gallery. It's a hack, I admit it, but it does the job for me and makes it much easier to add captions to my pictures.

Scott

If you add:
// Pull out keywords
$wlgkeyword = $sxe->xpath('//dc:subject/rdf:Bag/rdf:li');
$cswlgkeyword = implode(",", $wlgkeyword);
if ($addOption & IPTC_ITEM_KEYWORDS
&& (sizeof(wlgkeyword) > 0)) {
$currentItems[$i]->setKeywords(
$cswlgkeyword);
$mustSave = true;
}

to the buttom of your code it can also pull out keywords :)

 
wormie
wormie's picture

Joined: 2003-01-09
Posts: 19
Posted: Sat, 2009-01-03 09:52

Final update... In my photos the xmp tag is sometimes <xmp:xmpmeta> and other times <x:xmpmeta>. I added a quick "hack" to fix this but more experienced programmers can probably clean up my code quite a bit :)

This is svillinskis hack modified a bit so it also puls out keywords from the photos

Insert the following code after this

Quote:
else if (!empty($exifData[$itemId]['UserComment']['value'])) {
$itemDescription = $exifData[$itemId]['UserComment']['value'];
}

Quote:
// This section will pull out the Title from a Windows Live Photo Gallery picture
// Find the item based on the itemId
list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);
// Retrieve the path for the item
list ($ret, $path) = $item->fetchPath();

ob_start();
readfile($path);
$source = ob_get_contents();
ob_end_clean();

// Find the beginning and end of the XML string
$xmpdata_start = strpos($source,"<xmp:xmpmeta ");
$xmpdata_end = strpos($source,"</xmp:xmpmeta>");
if ($xmpdata_start<1) {
$xmpdata_start = strpos($source,"<x:xmpmeta ");
$xmpdata_end = strpos($source,"</x:xmpmeta>");
}
$xmplength= $xmpdata_end-$xmpdata_start;
if ($xmplength>0) {
$xmpdata = substr($source,$xmpdata_start,$xmplength+14);

$sxe = new SimpleXMLElement($xmpdata);

//Fetch all namespaces
$namespaces = $sxe->getNamespaces(true);

//Register them with their prefixes
foreach ($namespaces as $prefix => $ns) {
$sxe->registerXPathNamespace($prefix, $ns);
}

// Pull out the title
$result = $sxe->xpath('//dc:title/rdf:Alt/rdf:li');
if (sizeof($result) > 0) {
$itemDescription = $result[0];
}

// Pull out keywords
$wlgkeyword = $sxe->xpath('//dc:subject/rdf:Bag/rdf:li');
$cswlgkeyword = implode(",", $wlgkeyword);
if ($addOption & IPTC_ITEM_KEYWORDS
&& (sizeof(wlgkeyword) > 0)) {
$currentItems[$i]->setKeywords(
$cswlgkeyword);
$mustSave = true;
}
}

// End of Windows Live Photo Gallery additions

 
svillinski

Joined: 2008-07-31
Posts: 5
Posted: Sat, 2009-01-03 12:47

Thanks for the various commnts. The reason you have a different XML element is because you are probably running a more recent version of WLPG. We both get the end result, just if a slightly different way. Here's some changes I made in November (but didn't post here):

else if (!empty($exifData[$itemId]['UserComment']['value'])) {
$itemDescription = $exifData[$itemId]['UserComment']['value'];
}

// Here is the breakdown of the XMP tags for Windows Live Photo Gallery
//
// WLPG - Original Version
// Comments - /xmp:xmpmeta/rdf:RDF/rdf:Description/exit:UserComment/rdf:Alt/rdf:li
// Caption- /xmp:xmpmeta/rdf:RDF/rdf:Description/dc:title/rdf:Alt/rdf:li
// Subject - /xmp:xmpmeta/rdf:RDF/rdf:Description/dc:description/rdf:Alt/rdf:li
// Tag - /xmp:xmpmeta/rdf:RDF/rdf:Description/dc:subject/rdf:Bag/rdf:li
// Tag (XMP) - /xmp:xmpmeta/rdf:RDF/rdf:Description/MicrosoftPhoto:LastKeywordXMP/rdf:Bag/rdf:li
//
// WLPG - M3
// Comments - /x:xmpmeta/rdf:RDF/rdf:Description/exif:UserComment/rdf:Alt/rdf:li
// Caption - /x:xmpmeta/rdf:RDF/rdf:Description/dc:title/rdf:Alt/rdf:li
// Subject - /x:xmpmeta/rdf:RDF/rdf:Description/dc:description/rdf:Alt/rdf:li
// Tag - /x:xmpmeta/rdf:RDF/rdf:Description/dc:subject/rdf:Bag/rdf:li
// Tag (XMP) - /x:xmpmeta/rdf:RDF/rdf:Description/MicrosoftPhoto:LastKeywordXMP/rdf:Bag/rdf:li

// Set constants for reading out XML tags - same for Retail and M3
$XMPCaption = "//dc:title/rdf:Alt/rdf:li";
$XMPTag = "//MicrosoftPhoto:LastKeywordXMP/rdf:Bag/rdf:li";
$XMPComments = "//exif:UserComment/rdf:Alt/rdf:li";
$XMPSubject = "//dc:description/rdf:Alt/rdf:li";
$XMPRetailStart = "<xmp:xmpmeta ";
$XMPRetailEnd = "</xmp:xmpmeta>";
$XMPM3Start = "<x:xmpmeta ";
$XMPM3End = "</x:xmpmeta>";

// Enable Logging
$xmplogging = True;
$xmplogging_file = "c:\\windows\\temp\\scott.log";

// Find the item based on the itemId
if ($xmplogging) { error_log("Start of Item add: " . date('l jS \of F Y h:i:s A') . "\n", 3, $xmplogging_file);}
list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);

// Retrieve the path for the item
list ($ret, $path) = $item->fetchPath();
if ($xmplogging) {error_log(" Item path: " . $path . "\n", 3, $xmplogging_file);}

ob_start();
readfile($path);
$source = ob_get_contents();
ob_end_clean();

// Check to see if ":xmpmeta" exists, if so, then check to see which version it is
// Finding the beginning of the XMP stream for M3 version
$xmpdata_start = strpos($source, $XMPM3Start);
$xmpdata_end = strpos($source,$XMPM3End);
if ($xmpdata_start == false) {
// if ($xmplogging) { error_log("Checking to see if this is a Retail version file...\n", 3, $xmplogging_file);}
$xmpdata_start = strpos($source, $XMPRetailStart);
$xmpdata_end = strpos($source,$XMPRetailEnd);
}

if ($xmpdata_start < $xmpdata_end) {
if ($xmplogging) {error_log(" XMP Data exists\n", 3, $xmplogging_file);}
$xmplength= $xmpdata_end-$xmpdata_start;
$xmpdata = substr($source,$xmpdata_start,$xmplength+14);
$sxe = new SimpleXMLElement($xmpdata);

//Fetch all namespaces
$namespaces = $sxe->getNamespaces(true);

//Register them with their prefixes
foreach ($namespaces as $prefix => $ns) {
$sxe->registerXPathNamespace($prefix, $ns);
}

// Pull out the title (caption)
if ($xmplogging) {error_log(" Searching for XMP Title\n", 3, $xmplogging_file);}
$result = $sxe->xpath($XMPCaption);
if ($xmplogging) {error_log(" Title count: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
$currentItems[$i]->setTitle($result[0]);
$mustSave = true;
if ($xmplogging) {error_log(" Updated title: " . $result[0] . "\n", 3, $xmplogging_file);}
}

// Pull out the Keywords (tags)
if ($xmplogging) {error_log(" Searching for XMP Keywords\n", 3, $xmplogging_file);}
$keywords = "";
$result = $sxe->xpath($XMPTag);
if ($xmplogging) {error_log(" Keyword count: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
// Need to iterate through the $result to add all keywords to the keyword list
foreach ($result as $keyword) {
$keywords .= $keyword . ";";
}
$currentItems[$i]->setKeywords($keywords);
$mustSave = true;
if ($xmplogging) {error_log(" Updated keywords: " . $keywords . "\n" , 3, $xmplogging_file);}
}

// Pulling out the Subject to put in the Summary
if ($xmplogging) {error_log(" Searching for XMP Subject\n", 3, $xmplogging_file);}
$result = $sxe->xpath($XMPSubject);
if ($xmplogging) {error_log(" Summary count: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
$currentItems[$i]->setSummary($result[0]);
$mustSave = true;
if ($xmplogging) {error_log(" Updated summary: " . $result[0] . "\n", 3, $xmplogging_file);}
}
}
if ($xmplogging) { error_log("End of Item add: " . date('l jS \of F Y h:i:s A') . "\n\n", 3, $xmplogging_file);}
// End of Windows Live Photo Gallery additions

 
jeremy.riley

Joined: 2009-08-23
Posts: 1
Posted: Sun, 2009-08-23 09:14

Windows Live Photo Gallery now includes a 'people tagging' feature. I wanted to import this metadata into my Gallery in addition to the general tags. I have modified the above code to do this...

else if (!empty($exifData[$itemId]['UserComment']['value'])) {
$itemDescription = $exifData[$itemId]['UserComment']['value'];
}

// Here is the breakdown of the XMP tags for Windows Live Photo Gallery
//
// WLPG - Original Version
// Comments - /xmp:xmpmeta/rdf:RDF/rdf:Description/exit:UserComment/rdf:Alt/rdf:li
// Caption- /xmp:xmpmeta/rdf:RDF/rdf:Description/dc:title/rdf:Alt/rdf:li
// Subject - /xmp:xmpmeta/rdf:RDF/rdf:Description/dc:description/rdf:Alt/rdf:li
// Tag - /xmp:xmpmeta/rdf:RDF/rdf:Description/dc:subject/rdf:Bag/rdf:li
// Tag (XMP) - /xmp:xmpmeta/rdf:RDF/rdf:Description/MicrosoftPhoto:LastKeywordXMP/rdf:Bag/rdf:li
//
// WLPG - M3
// Comments - /x:xmpmeta/rdf:RDF/rdf:Description/exif:UserComment/rdf:Alt/rdf:li
// Caption - /x:xmpmeta/rdf:RDF/rdf:Description/dc:title/rdf:Alt/rdf:li
// Subject - /x:xmpmeta/rdf:RDF/rdf:Description/dc:description/rdf:Alt/rdf:li
// Tag - /x:xmpmeta/rdf:RDF/rdf:Description/dc:subject/rdf:Bag/rdf:li
// Tag (XMP) - /x:xmpmeta/rdf:RDF/rdf:Description/MicrosoftPhoto:LastKeywordXMP/rdf:Bag/rdf:li
// Set constants for reading out XML tags - same for Retail and M3
$XMPCaption = "//dc:title/rdf:Alt/rdf:li";
$XMPTag = "//MicrosoftPhoto:LastKeywordXMP/rdf:Bag/rdf:li";
//JR Extended tag query to include PersonDisplayName from Windows Live Photo Gallery person tagging
$XMPTag2 = "//MPRI:Regions/rdf:Bag/rdf:li/rdf:Description/MPReg:PersonDisplayName";
$XMPComments = "//exif:UserComment/rdf:Alt/rdf:li";
$XMPSubject = "//dc:description/rdf:Alt/rdf:li";
$XMPRetailStart = "<xmp:xmpmeta ";
$XMPRetailEnd = "</xmp:xmpmeta>";
$XMPM3Start = "<x:xmpmeta ";
$XMPM3End = "</x:xmpmeta>";

// Enable Logging
//$xmplogging = True;
$xmplogging = False;
$xmplogging_file = "/home/moorscap/var/g2data/exifupload.log";

// Find the item based on the itemId
if ($xmplogging) { error_log("Start of Item add: " . date('l jS \of F Y h:i:s A') . "\n", 3, $xmplogging_file);}
list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);

// Retrieve the path for the item
list ($ret, $path) = $item->fetchPath();
if ($xmplogging) {error_log(" Item path: " . $path . "\n", 3, $xmplogging_file);}

ob_start();
readfile($path);
$source = ob_get_contents();
ob_end_clean();

// Check to see if ":xmpmeta" exists, if so, then check to see which version it is
// Finding the beginning of the XMP stream for M3 version
$xmpdata_start = strpos($source, $XMPM3Start);
$xmpdata_end = strpos($source,$XMPM3End);
if ($xmpdata_start == false) {
// if ($xmplogging) { error_log("Checking to see if this is a Retail version file...\n", 3, $xmplogging_file);}
$xmpdata_start = strpos($source, $XMPRetailStart);
$xmpdata_end = strpos($source,$XMPRetailEnd);
}

if ($xmpdata_start < $xmpdata_end) {
if ($xmplogging) {error_log(" XMP Data exists\n", 3, $xmplogging_file);}
$xmplength= $xmpdata_end-$xmpdata_start;
$xmpdata = substr($source,$xmpdata_start,$xmplength+14);
$sxe = new SimpleXMLElement($xmpdata);

//Fetch all namespaces
$namespaces = $sxe->getNamespaces(true);

//Register them with their prefixes
foreach ($namespaces as $prefix => $ns) {
$sxe->registerXPathNamespace($prefix, $ns);
}

// Pull out the title (caption)
if ($xmplogging) {error_log(" Searching for XMP Title\n", 3, $xmplogging_file);}
$result = $sxe->xpath($XMPCaption);
if ($xmplogging) {error_log(" Title count: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
$currentItems[$i]->setTitle($result[0]);
$mustSave = true;
if ($xmplogging) {error_log(" Updated title: " . $result[0] . "\n", 3, $xmplogging_file);}
}

// Pull out the Keywords (tags)
if ($xmplogging) {error_log(" Searching for XMP Keywords\n", 3, $xmplogging_file);}
$keywords = "";
$result = $sxe->xpath($XMPTag);
if ($xmplogging) {error_log(" Keyword count: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
// Need to iterate through the $result to add all keywords to the keyword list
foreach ($result as $keyword) {
$keywords .= $keyword . ";";
}
}
$result = $sxe->xpath($XMPTag2);
if ($xmplogging) {error_log(" Keyword count2: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
// Need to iterate through the $result to add all keywords to the keyword list
foreach ($result as $keyword) {
$keywords .= $keyword . ";";
}
}
if ($keywords != "") {
$currentItems[$i]->setKeywords($keywords);
$mustSave = true;
if ($xmplogging) {error_log(" Updated keywords: " . $keywords . "\n" , 3, $xmplogging_file);}
}

// Pulling out the Subject to put in the Summary
if ($xmplogging) {error_log(" Searching for XMP Subject\n", 3, $xmplogging_file);}
$result = $sxe->xpath($XMPSubject);
if ($xmplogging) {error_log(" Summary count: " . sizeof($result) . "\n", 3, $xmplogging_file);}
if (sizeof($result) > 0) {
$currentItems[$i]->setSummary($result[0]);
$mustSave = true;
if ($xmplogging) {error_log(" Updated summary: " . $result[0] . "\n", 3, $xmplogging_file);}
}
}
if ($xmplogging) { error_log("End of Item add: " . date('l jS \of F Y h:i:s A') . "\n\n", 3, $xmplogging_file);}
// End of Windows Live Photo Gallery additions

 
dstalls

Joined: 2010-04-06
Posts: 6
Posted: Tue, 2010-04-06 18:56

I am using the "Publish on Gallery2" add-in with WLPG. Will the above code allow me to upload the tags in my photos to my Gallery2 website? If so where do i put this file? I love gallery2 and have used it for years but now I manage all my photos with WLPG and need to easy upload the tags at the same time. Thanks.

 
dstalls

Joined: 2010-04-06
Posts: 6
Posted: Wed, 2010-04-07 05:35

Well after editing the file above I see that it does work with the WLPG upload. However is there any way to get the names to display when you hover over the person, like on Facebook?

Also, it dumps everything into keywords. WLPG has people tags and description tags. Is there a way to create a custom field in g2 for people tags and another field for description tags. Kind of like FB which as a field under the picture "In this photo: ....."

Thanks!