diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-02-15 08:08:22 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-02-15 08:08:22 +0000 |
commit | 590a4677f34f866911fa6c0902130f8dbea7421a (patch) | |
tree | e099100f14d048d6f8725f65af4c4a8f4009c130 /modules/exif/helpers/exif.php | |
parent | eb3e2359a7301588b16e0f29e96242fa48a39e6f (diff) |
Tweak EXIF extraction code to be more robust.
* Create Exif_Record_Model to track whether we've scanned the EXIF
data for this photo or not. This allows us to track photos that
don't have EXIF data (and won't have any Exif_Keys)
* Blow away old Exif_Keys when extracting, else we hit unique
index constraints.
* exif::_get_stats() -- before it was running the task forever
Diffstat (limited to 'modules/exif/helpers/exif.php')
-rw-r--r-- | modules/exif/helpers/exif.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index ee128353..55877140 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -22,10 +22,12 @@ * This is the API for handling exif data. */ class exif_Core { - + protected static $exif_keys; - + public static function extract($item) { + ORM::factory("exif_key")->where("item_id", $item->id)->delete_all(); + // Only try to extract EXIF from photos if ($item->is_photo() && $item->mime_type == "image/jpeg") { require_once(MODPATH . "exif/lib/exif.php"); @@ -57,6 +59,13 @@ class exif_Core { } } } + + $record = ORM::factory("exif_record")->where("item_id", $item->id)->find(); + if (!$record->loaded) { + $record->item_id = $item->id; + } + $record->dirty = 0; + $record->save(); } public static function get($item, $summary=true) { @@ -71,10 +80,10 @@ class exif_Core { foreach ($keys as $key) { $exif[] = array("caption" => $definitions[$key->name][2], "value" => $key->value); } - + return $exif; } - + private static function _keys() { if (!isset(self::$exif_keys)) { |