take commands from database
This commit is contained in:
parent
1ac8009173
commit
3ccc525313
@ -3,6 +3,7 @@
|
|||||||
namespace App\Jobs;
|
namespace App\Jobs;
|
||||||
|
|
||||||
use App\Models\PhotoJob;
|
use App\Models\PhotoJob;
|
||||||
|
use App\Models\Photoprofile;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
use Illuminate\Support\Facades\Process;
|
use Illuminate\Support\Facades\Process;
|
||||||
@ -20,12 +21,14 @@ class ConvertToComic implements ShouldQueue
|
|||||||
{
|
{
|
||||||
$absolutePath = Storage::disk('public')->path($this->photoJob->image_path);
|
$absolutePath = Storage::disk('public')->path($this->photoJob->image_path);
|
||||||
|
|
||||||
$command = 'gmic ' . escapeshellarg($absolutePath) .
|
$photoprofile = Photoprofile::where('active', 1)->first();
|
||||||
' simplelocalcontrast_p 16,2,0,1,1,1,1,1,1,1,1,0' .
|
$photocommands = [];
|
||||||
' -o ' . escapeshellarg($absolutePath) .
|
foreach (explode(PHP_EOL, $photoprofile->commands) as $command) {
|
||||||
' && gmic ' . escapeshellarg($absolutePath) .
|
if (count($photocommands) > 0) $photocommands[] = ' && gmic ' . escapeshellarg($absolutePath) . ' ' . $command . ' -o ' . escapeshellarg($absolutePath);
|
||||||
' cl_comic 4,1,0,0,1,15,15,1,10,20,6,2,0,0,0,0,0,0,50,50' .
|
else $photocommands[] = 'gmic ' . escapeshellarg($absolutePath) . ' ' . $command . ' -o ' . escapeshellarg($absolutePath);
|
||||||
' -o ' . escapeshellarg($absolutePath);
|
}
|
||||||
|
$command = implode($photocommands);
|
||||||
|
|
||||||
$result = Process::timeout(0)->run($command);
|
$result = Process::timeout(0)->run($command);
|
||||||
|
|
||||||
$this->photoJob->update([
|
$this->photoJob->update([
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
@ -10,11 +9,10 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
use WithoutModelEvents;
|
use WithoutModelEvents;
|
||||||
|
|
||||||
/**
|
|
||||||
* Seed the application's database.
|
|
||||||
*/
|
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
//
|
$this->call([
|
||||||
|
PhotoprofileSeeder::class,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
database/seeders/PhotoprofileSeeder.php
Normal file
25
database/seeders/PhotoprofileSeeder.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Photoprofile;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class PhotoprofileSeeder extends Seeder
|
||||||
|
{
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$profiles = [
|
||||||
|
[
|
||||||
|
'name' => 'Standard',
|
||||||
|
'active' => true,
|
||||||
|
'commands' => 'simplelocalcontrast_p 16,2,0,1,1,1,1,1,1,1,1,0
|
||||||
|
cl_comic 4,1,0,0,1,15,15,1,10,20,6,2,0,0,0,0,0,0,50,50',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($profiles as $profile) {
|
||||||
|
Photoprofile::firstOrCreate(['name' => $profile['name']], $profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user