77 lines
2.4 KiB
PHP
77 lines
2.4 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* Mark all accounts that have no outstanding invoices and active services as disabled.
|
|
*
|
|
* @package Photo
|
|
* @category Tasks
|
|
* @author Deon George
|
|
* @copyright (c) 2014 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
*/
|
|
class Task_Photo_Import extends Minion_Task {
|
|
protected $_options = array(
|
|
'file'=>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->list_duplicate()->find_all()->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);
|
|
}
|
|
|
|
// Force the return of a string or NULL
|
|
private function dbcol($val,$noval=NULL) {
|
|
return $val ? (string)$val : $noval;
|
|
}
|
|
}
|
|
?>
|