NULL, // Photo File to Import 'verbose'=>FALSE, // Photo File to Import ); protected function _execute(array $params) { if (is_null($params['file'])) throw new Kohana_Exception('Missing filename, please use --file='); if (preg_match('/@__thumb/',$params['file']) OR preg_match('/\/._/',$params['file'])) return sprintf("Ignoring file [%s]\n",$params['file']); $po = ORM::factory('Photo',array('filename'=>$params['file'])); if (! $po->loaded()) $po->filename = $params['file']; $po->date_taken = $this->dbcol(strtotime($po->io('exif:DateTime'))); $po->signature = $this->dbcol($po->io()->getImageSignature()); $po->make = $this->dbcol($po->io('exif:Make')); $po->model = $this->dbcol($po->io('exif:Model')); $po->height = $this->dbcol($po->io()->getImageheight()); $po->width = $this->dbcol($po->io()->getImageWidth()); $po->orientation = $this->dbcol($po->io()->getImageOrientation()); $po->subsectime = $this->dbcol($po->io('exif:SubSecTimeOriginal')); $po->gps_lat = $this->dbcol($po->gps(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLatitude')),$po->io()->getImageProperty('exif:GPSLatitudeRef'))); $po->gps_lon = $this->dbcol($po->gps(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLongitude')),$po->io()->getImageProperty('exif:GPSLongitudeRef'))); try { $po->thumbnail = $this->dbcol(exif_thumbnail($po->filename)); } catch (Exception $e) { } switch ($params['verbose']) { case 1: print_r($po->what_changed()); break; case 2: print_r($po->io()->getImageProperties()); break; } if ($po->duplicate_get()->count()) $po->duplicate = '1'; if (! $po->changed()) return sprintf("Image [%s] already in DB: %s\n",$params['file'],$po->id); $po->save(); if ($po->saved()) return sprintf("Image [%s] stored in DB: %s\n",$params['file'],$po->id); return sprintf("Image [%s] processed in DB: %s\n",$params['file'],$po->id); } private function dbcol($val,$noval=NULL) { return $val ? (string)$val : $noval; } } ?>