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

@ -144,8 +144,8 @@ class Import extends Command
$po->width = $po->io()->getImageWidth();
$po->orientation = $po->io()->getImageOrientation();
$po->gps_lat = $po->gps(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLatitude')),$po->io()->getImageProperty('exif:GPSLatitudeRef'));
$po->gps_lon = $po->gps(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLongitude')),$po->io()->getImageProperty('exif:GPSLongitudeRef'));
$po->gps_lat = $po->latlon(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLatitude')),$po->io()->getImageProperty('exif:GPSLatitudeRef'));
$po->gps_lon = $po->latlon(preg_split('/,\s?/',$po->io()->getImageProperty('exif:GPSLongitude')),$po->io()->getImageProperty('exif:GPSLongitudeRef'));
try {
$po->thumbnail = exif_thumbnail($po->file_path());

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');

View File

@ -8,7 +8,40 @@
<div class="panel-heading">Photo <?php echo $photo->id; ?></div>
<div class="panel-body">
<img src="/thumbnail/<?php echo $photo->id; ?>">
<div class="col-md-2"><img src="/thumbnail/<?php echo $photo->id; ?>" width="200px"></div>
<div class="col-md-10">
<div class="dl-horizontal">
<dt>Filename</dt><dd><?php echo $photo->file_path(TRUE); ?></dd>
<?php if ($photo->shouldMove()) : ?>
<dt>NEW Filename</dt><dd><?php echo $photo->file_path(TRUE,TRUE); ?></dd>
<?php endif ?>
<br/>
<dt>Date Taken</dt><dd><?php echo $photo->date_taken(); ?></dd>
<dt>Camera</dt><dd><?php echo $photo->make; ?></dd>
<dt>Model</dt><dd><?php echo $photo->model; ?></dd>
<br/>
<dt>Location</dt><dd>
<?php if ($photo->gps() == 'UNKNOWN') : ?>
UNKNOWN
<?php else : ?>
<div id="map" style="width: 400px; height: 300px"></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var myLatLng = {lat: <?php echo $photo->gps_lat; ?>, lng: <?php echo $photo->gps_lon; ?>};
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 16,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new google.maps.Marker({
map: map,
position: myLatLng,
});
</script>
<?php endif ?>
</dd>
</div>
</div>
</div>
</div>
</div>