From fc6bdbbbc829b38c020c190e06e3fe5892bac1a0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 7 May 2009 01:18:31 +0000 Subject: Grab photo capture date and captions from EXIF/IPTC data. - Add a "captured" column to the items table. - Pull the DateTime EXIF field and put it into the captured column - Pull the Caption EXIF & IPTC fields and put them into the description field if there was not already a value there --- modules/exif/helpers/exif.php | 12 ++++++++++++ modules/info/views/info_block.html.php | 6 ++++++ 2 files changed, 18 insertions(+) (limited to 'modules') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index 25d9eadd..e185ac8a 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -43,8 +43,15 @@ class exif_Core { } $data[] = sprintf("(%d, '%s', '%s')", $item->id, $field, $db->escape_str($value)); } + + if ($field == "DateTime") { + $item->captured = strtotime($value); + } else if ($field == "Caption" && !$item->description) { + $item->description = $value; + } } } + $size = getimagesize($item->file_path(), $info); if (is_array($info) && !empty($info["APP13"])) { $iptc = iptcparse($info["APP13"]); @@ -59,6 +66,10 @@ class exif_Core { $item->id, $keyword, $db->escape_str($value)); } + + if ($keyword == "Caption" && !$item->description) { + $item->description = $value; + } } } @@ -70,6 +81,7 @@ class exif_Core { $db->query($query); } } + $item->save(); $record = ORM::factory("exif_record")->where("item_id", $item->id)->find(); if (!$record->loaded) { diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php index 956cc23d..880d5d3e 100644 --- a/modules/info/views/info_block.html.php +++ b/modules/info/views/info_block.html.php @@ -17,6 +17,12 @@ name; ?> + captured): ?> + + + captured)?> + + owner): ?> -- cgit v1.2.3