Added some info to the view

This commit is contained in:
Deon George
2016-06-22 16:51:31 +10:00
parent b1d7cfe616
commit e297c5ca7e
3 changed files with 87 additions and 15 deletions

View File

@@ -19,6 +19,10 @@ class Photo extends Model
8=>-90,
];
public function date_taken() {
return $this->date_taken ? (date('Y-m-d H:i:s',$this->date_taken).($this->subsectime ? '.'.$this->subsectime : '')) : 'UNKNOWN';
}
/**
* Determine the new name for the image
*/
@@ -33,7 +37,35 @@ class Photo extends Model
return (($short OR preg_match('/^\//',$file)) ? '' : config('photo.dir').DIRECTORY_SEPARATOR).$file;
}
public function gps(array $coordinate,$hemisphere) {
/**
* Calculate a file path ID based on the id of the file
*/
public function file_path_id($sep=3,$depth=9) {
return trim(chunk_split(sprintf("%0{$depth}s",$this->id),$sep,'/'),'/');
}
/**
* Display the GPS coordinates
*/
public function gps() {
return ($this->gps_lat AND $this->gps_lon) ? sprintf('%s/%s',$this->gps_lat,$this->gps_lon) : 'UNKNOWN';
}
/**
* Return an Imagick object or attribute
*
*/
public function io($attr=NULL) {
if (is_null($this->_io))
$this->_io = new \Imagick($this->file_path());
return is_null($attr) ? $this->_io : $this->_io->getImageProperty($attr);
}
/**
* Calculate the GPS coordinates
*/
public function latlon(array $coordinate,$hemisphere) {
if (! $coordinate OR ! $hemisphere)
return NULL;
@@ -57,17 +89,6 @@ class Photo extends Model
return round($sign*($degrees+$minutes/60+$seconds/3600),$degrees > 100 ? 3 : 4);
}
/**
* Return an Imagick object or attribute
*
*/
public function io($attr=NULL) {
if (is_null($this->_io))
$this->_io = new \Imagick($this->file_path());
return is_null($attr) ? $this->_io : $this->_io->getImageProperty($attr);
}
/**
* Rotate the image
*
@@ -80,6 +101,14 @@ class Photo extends Model
return $imo->getImageBlob();
}
/**
* Determine if the image should be moved
*/
public function shouldMove()
{
return ($this->filename != $this->file_path(TRUE,TRUE));
}
/**
* Return the image's thumbnail
*
@@ -98,6 +127,16 @@ class Photo extends Model
return $this->rotate($imo);
}
/**
* Return the extension of the image
*/
public function type($mime=FALSE) {
return strtolower($mime ? File::mime_by_ext(pathinfo($this->filename,PATHINFO_EXTENSION)) : pathinfo($this->filename,PATHINFO_EXTENSION));
}
/**
* Find duplicate images based on some attributes of the current image
*/
public function list_duplicate() {
$po = DB::table('photo');