From 917aea2f2d70d7a1bbe859cf518235cd982c8118 Mon Sep 17 00:00:00 2001 From: Isaac Date: Fri, 24 Nov 2017 21:20:44 -0800 Subject: [PATCH] Implemented Commands/resizeImages --- app/Console/Commands/ResizeImages.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/ResizeImages.php b/app/Console/Commands/ResizeImages.php index 0473f107..b121c348 100644 --- a/app/Console/Commands/ResizeImages.php +++ b/app/Console/Commands/ResizeImages.php @@ -3,6 +3,8 @@ namespace Poniverse\Ponyfm\Console\Commands; use Illuminate\Console\Command; +use Poniverse\Ponyfm\Models\Image; +use Symfony\Component\HttpFoundation\File\File; class ResizeImages extends Command { @@ -33,10 +35,19 @@ class ResizeImages extends Command /** * Execute the console command. * - * @return mixed + * @return void */ public function handle() { + $images = Image::all(); + foreach ($images as $image) { + $this->info("Regenerating images for ".$image->filename); + $image->clearExisting(); + $originalFile = new File($image->getFile(Image::ORIGINAL)); + foreach (Image::$ImageTypes as $imageType) { + Image::processFile($originalFile, $image->getFile($imageType['id']), $imageType); + } + } } }