From 3ccc52531398c49751614872afdba1cb0bd4831f Mon Sep 17 00:00:00 2001 From: Alexander Gabriel Date: Sun, 28 Jun 2026 15:16:49 +0000 Subject: [PATCH] take commands from database --- app/Jobs/ConvertToComic.php | 15 +++++++++------ database/seeders/DatabaseSeeder.php | 8 +++----- database/seeders/PhotoprofileSeeder.php | 25 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 database/seeders/PhotoprofileSeeder.php diff --git a/app/Jobs/ConvertToComic.php b/app/Jobs/ConvertToComic.php index 99c9e2a..e0882ee 100644 --- a/app/Jobs/ConvertToComic.php +++ b/app/Jobs/ConvertToComic.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\PhotoJob; +use App\Models\Photoprofile; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; use Illuminate\Support\Facades\Process; @@ -20,12 +21,14 @@ class ConvertToComic implements ShouldQueue { $absolutePath = Storage::disk('public')->path($this->photoJob->image_path); - $command = 'gmic ' . escapeshellarg($absolutePath) . - ' simplelocalcontrast_p 16,2,0,1,1,1,1,1,1,1,1,0' . - ' -o ' . escapeshellarg($absolutePath) . - ' && gmic ' . escapeshellarg($absolutePath) . - ' cl_comic 4,1,0,0,1,15,15,1,10,20,6,2,0,0,0,0,0,0,50,50' . - ' -o ' . escapeshellarg($absolutePath); + $photoprofile = Photoprofile::where('active', 1)->first(); + $photocommands = []; + foreach (explode(PHP_EOL, $photoprofile->commands) as $command) { + if (count($photocommands) > 0) $photocommands[] = ' && gmic ' . escapeshellarg($absolutePath) . ' ' . $command . ' -o ' . escapeshellarg($absolutePath); + else $photocommands[] = 'gmic ' . escapeshellarg($absolutePath) . ' ' . $command . ' -o ' . escapeshellarg($absolutePath); + } + $command = implode($photocommands); + $result = Process::timeout(0)->run($command); $this->photoJob->update([ diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 34dd1c0..e00b4dd 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use App\Models\User; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; @@ -10,11 +9,10 @@ class DatabaseSeeder extends Seeder { use WithoutModelEvents; - /** - * Seed the application's database. - */ public function run(): void { - // + $this->call([ + PhotoprofileSeeder::class, + ]); } } diff --git a/database/seeders/PhotoprofileSeeder.php b/database/seeders/PhotoprofileSeeder.php new file mode 100644 index 0000000..a88531b --- /dev/null +++ b/database/seeders/PhotoprofileSeeder.php @@ -0,0 +1,25 @@ + '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); + } + } +}