Migrating Gallery Metadata

For a number of years back in the day I used the gallery.menalto.com software to host an online gallery of photos. Back in this rough and tumble wild
west days of metadata there weren’t great standards that could handle all possible metadata cases – and so the metadata was all stored in serialized php objects.

Fast forward to today, where there are great ways to store metadata for a photo right there with the photo. You can have exif, xmp, an iptc (to name some popular choices) and all the photo applications are aware enough to use that data. I only had limited meta data in the gallery software (title, caption, comments) but I had thousands of photos and the idea of entering that stuff in by hand was not appealing, neither was throwing it away. Thus I wrote some code to deal with it. It isn’t pretty and isn’t super fast but it does work.

The unserialize.php script is fairly straight forward, you feed it a photos.dat file and it spits out a line for each photo with filename, title, caption, comments and if the file was hidden or not.

unserialize.php:

#!/usr/bin/php

image;
$title = $obj->phototitle; # extraFields->Title
$cap = $obj->caption;
$hidden = $obj->hidden;

# There can be multiple comments so build a little xml of all the
# comment content that can be output as a single string.
$comments = $obj->comments;
$commentXML = “”;
if ( $comments != null) {
# var_dump($comments); #debug
$commentXML = ““;
foreach ($comments as $comment) {
$text = $comment->commentText;
$text = preg_replace(“[\n\r]”,”
“, $text);
$name = $comment->name;
$datePosted = $comment->datePosted;

$commentXML .= “$name” . date(“Y-m-d H:i:s”, $datePosted) . “$text This entry was posted in Uncategorized by eric. Bookmark the permalink.