#!/usr/bin/php5 isAlbumName) { // C'est un sous-album $filename = $gallery . '/' . $albumitem->isAlbumName . '/' . 'album.dat'; $fd = fopen($filename, "r"); $contents = fread($fd, filesize($filename)); fclose($fd); $album_data = unserialize($contents); $n = sprintf("%02d %s %s", $index, ($albumitem->isHidden()!=0)?"#":"-", html_entity_decode($album_data->fields["title"])); $n = mb_convert_encoding($n, "UTF-8"); processGalleryAlbum($gallery, $albumitem->isAlbumName, $targetdir, $n); } elseif (($albumitem->image->name)) { // C'est une image if ($albumitem->caption) $n = sprintf("%02d %s %s - %s", $index, ($albumitem->isHidden()!=0)?"#":"-", $albumitem->image->name, $albumitem->caption); else $n = sprintf("%02d - %s", $index, $albumitem->image->name); if ($display) print "[IMG] " . $album . '/' . $albumitem->image->name . "." . $albumitem->image->type . " -> " . $targetdir . "/" . $n. "\n"; $text = $albumitem->caption; if (array_key_exists('Description', $albumitem->extraFields)) if ($albumitem->extraFields['Description'] != '') $text .= "\n\n" . $albumitem->extraFields['Description']; $in = $gallery . '/' . $album . '/' . $albumitem->image->name . "." . $albumitem->image->type; unset($output); exec("exiftool -comment -s -s -s $in",$output); $comment = implode("\n",$output); //$comment = mb_convert_encoding($comment, "UTF-8"); print "[IMG] " . $albumitem->image->name . " : " . $comment . " \n"; $albumitem->caption = $comment; } $index++; } print "Save changes in $photosfilename"; copy($photosfilename,$photosfilename . ".bk"); $contents = serialize($data); $fd = fopen($photosfilename, "w"); fwrite($fd, $contents); fclose($fd); } function main($argc, $argv) { $gallery = $argv[1]; $album = $argv[2]; $targetdir = ""; //$argv[3]; if ($album == '.') { $filename = $gallery . '/' . 'albumdb.dat'; $fd = fopen($filename, "r"); $contents = fread($fd, filesize($filename)); fclose($fd); $data = unserialize($contents); foreach($data as $album) { $filename = $gallery . '/' . $album . '/' . 'album.dat'; $fd = fopen($filename, "r"); $contents = fread($fd, filesize($filename)); fclose($fd); $album_data = unserialize($contents); if (!$album_data->fields['parentAlbumName']) { processGalleryAlbum($gallery, $album, $targetdir); } } } else { processGalleryAlbum($gallery, $album, $targetdir); } } main($argc, $argv); ?>