Minor fixes and support for HEIC images

This commit is contained in:
Deon George 2020-01-02 09:42:59 +11:00
parent fe155525a3
commit c5fcfdc1d7
7 changed files with 49 additions and 14 deletions

View File

@ -5,7 +5,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Bus\DispatchesJobs;
use App\Jobs\VideoMove;
use App\Jobs\{PhotoMove,VideoMove};
class CatalogMove extends Command
{
@ -52,9 +52,14 @@ class CatalogMove extends Command
}
switch (strtolower($this->argument('type'))) {
case 'photo':
$this->dispatch((new PhotoMove($o))->onQueue('move'));
break;
case 'video':
$this->dispatch((new VideoMove($o))->onQueue('move'));
break;
default:
$this->error('Dont know how to handle: ',$this->argument('type'));
}
}
}

View File

@ -71,7 +71,7 @@ class CatalogScan extends Command
if ($o->getDirty()) {
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
//dump($o->getDirty());
dump(['id'=>$o->id,'data'=>$o->getDirty()]);
}
$o->save();

View File

@ -39,7 +39,7 @@ class PhotoController extends Controller
{
return view('catalog.deletereview',[
'return'=>url('p/deletes'),
'catalog'=>is_null($id) ? Photo::where('remove',1)->with('software.model.make')->paginate($this->list_deletes) : Photo::where('id',$id)->paginate(1)
'catalog'=>is_null($id) ? Photo::where('remove',1)->with(['software.model.make'])->paginate($this->list_deletes) : Photo::where('id',$id)->paginate(1)
]);
}
@ -60,7 +60,7 @@ class PhotoController extends Controller
{
return view('catalog.duplicatereview',[
'return'=>url('p/duplicates'),
'catalog'=>is_null($id) ? Photo::notRemove()->where('duplicate',1)->with('software.model.make')->paginate($this->list_duplicates) : Photo::where('id',$id)->paginate(1)
'catalog'=>is_null($id) ? Photo::notRemove()->where('duplicate',1)->with(['software.model.make'])->paginate($this->list_duplicates) : Photo::where('id',$id)->paginate(1)
]);
}

View File

@ -37,7 +37,7 @@ class VideoController extends Controller
{
return view('catalog.deletereview',[
'return'=>url('v/deletes'),
'catalog'=>is_null($id) ? Video::where('remove',1)->paginate(50) : Video::where('id',$id)->paginate(1)
'catalog'=>is_null($id) ? Video::where('remove',1)->with(['software.model.make'])->paginate(50) : Video::where('id',$id)->paginate(1)
]);
}
@ -63,7 +63,7 @@ class VideoController extends Controller
{
return view('catalog.duplicatereview',[
'return'=>url('v/duplicates'),
'catalog'=>is_null($id) ? Video::notRemove()->where('duplicate',1)->paginate(50) : Video::where('id',$id)->paginate(1)]);
'catalog'=>is_null($id) ? Video::notRemove()->where('duplicate',1)->with(['software.model.make'])->paginate(50) : Video::where('id',$id)->paginate(1)]);
}
public function duplicatesUpdate(Request $request)

View File

@ -13,21 +13,42 @@ abstract class Catalog extends Model
{
protected static $includeSubSecTime = FALSE;
/**
* People in Multimedia Object
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function people()
{
return $this->belongsToMany(Person::class);
}
/**
* Software used to create Multimedia Object
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function software()
{
return $this->belongsTo(Software::class);
}
/**
* Tags added to Multimedia Object
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function tags()
{
return $this->belongsToMany(Tag::class);
}
/**
* Search Database for duplicates of this object
*
* @param $query
* @return mixed
*/
public function scopeDuplicates($query) {
if (! $this->exists)
return $query;
@ -102,6 +123,7 @@ abstract class Catalog extends Model
});
}
// Children objects must inherit this methods
abstract public function setDateCreated();
abstract public function setLocation();
abstract public function setSignature();

View File

@ -133,6 +133,7 @@ class Photo extends Abstracted\Catalog
if (array_key_exists($this->orientation,$this->_rotate))
$imo->rotateImage(new \ImagickPixel('none'),$this->_rotate[$this->orientation]);
$imo->setImageFormat('jpg');
return $imo->getImageBlob();
}
@ -236,7 +237,13 @@ class Photo extends Abstracted\Catalog
public function thumbnail($rotate=TRUE)
{
if (! $this->thumbnail) {
return $this->o()->thumbnailimage(200,200,true,true) ? $this->_o->getImageBlob() : NULL;
if ($this->o()->thumbnailimage(200,200,true,false)) {
$this->_o->setImageFormat('jpg');
return $this->_o->getImageBlob();
} else {
return NULL;
}
}
if (! $rotate OR ! array_key_exists($this->orientation,$this->_rotate) OR ! extension_loaded('imagick'))
@ -244,6 +251,7 @@ class Photo extends Abstracted\Catalog
$imo = new \Imagick();
$imo->readImageBlob($this->thumbnail);
$imo->setImageFormat('jpg');
return $this->rotate($imo);
}

View File

@ -3,6 +3,6 @@
return [
'dir'=>'/photos',
'import'=>[
'accepted'=>['jpg','jpeg'],
'accepted'=>['jpg','jpeg','heic'],
],
];