When an image is uploaded (i.e. created) the tag module will now extract any iptc keywords and add them as image tags.

This commit is contained in:
Tim Almdal
2008-11-28 18:04:59 +00:00
parent 4d71975f37
commit a7f6efa2f2

View File

@@ -97,7 +97,24 @@ class tag_Core {
*/
public static function on_photo_create() {
$photo = Event::$data;
Kohana::log("debug", "tag::on_photo_create($photo->name)");
$path = $photo->file_path();
$tags = array();
$size = getimagesize($photo->file_path(), $info);
if (is_array($info)) {
$iptc = iptcparse($info["APP13"]);
if (!empty($iptc["2#025"])) {
foreach($iptc["2#025"] as $tag) {
$tags[$tag]= 1;
}
}
}
// @todo figure out how to read the keywords from xmp
foreach(array_keys($tags) as $tag) {
self::add($photo, $tag);
}
return;
}