XMP support available?
|
Bascy
Joined: 2008-06-18
Posts: 5 |
Posted: Tue, 2008-07-01 19:19
|
|
Hi, Is there anything available to have gallery2 use XMP tags that are i.e. put there by Microsoft Live Photo gallery? |
|
| Login or register to post comments |

Posts: 32506
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
Posts: 5
are there any plans to support this in the future?
Is it on some wishlist maybe?
Posts: 32506
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
Posts: 5
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
Posts: 18
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
Posts: 18
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
Posts: 5
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
Posts: 1
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