diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2009-05-07 01:18:31 +0000 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-07 01:18:31 +0000 |
| commit | fc6bdbbbc829b38c020c190e06e3fe5892bac1a0 (patch) | |
| tree | 8b8bd0282cf341b8626bdf0be8e99af5f203d1b6 /modules | |
| parent | 934bc1e1f15405e7c4adb9d5bf59bad7680c5d79 (diff) | |
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
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/exif/helpers/exif.php | 12 | ||||
| -rw-r--r-- | modules/info/views/info_block.html.php | 6 |
2 files changed, 18 insertions, 0 deletions
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 @@ <td><?= $item->name; ?></td> </tr> <? endif ?> + <? if ($item->captured): ?> + <tr> + <th><?= t("Captured:") ?></th> + <td><?= date("M j, Y H:i:s", $item->captured)?></td> + </tr> + <? endif ?> <? if ($item->owner): ?> <tr> <th><?= t("Owner:") ?></th> |
