Implemented Commands/resizeImages

This commit is contained in:
Isaac 2017-11-24 21:20:44 -08:00
parent d8b9795ddc
commit 917aea2f2d

View file

@ -3,6 +3,8 @@
namespace Poniverse\Ponyfm\Console\Commands; namespace Poniverse\Ponyfm\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Poniverse\Ponyfm\Models\Image;
use Symfony\Component\HttpFoundation\File\File;
class ResizeImages extends Command class ResizeImages extends Command
{ {
@ -33,10 +35,19 @@ class ResizeImages extends Command
/** /**
* Execute the console command. * Execute the console command.
* *
* @return mixed * @return void
*/ */
public function handle() 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);
}
}
} }
} }