public function run() { $profiles = ['Thumbnail' => ['description' => 'A small (150x100) image to serve as thumbnails for galleries', 'slug' => 'thumbnail', 'transforms' => json_encode(['fit' => [150, 100]])], 'Dropzone Thumbnail' => ['description' => 'A 120x120 thumbnail, primarily used by the admin panel', 'slug' => 'dz-thumb', 'transforms' => json_encode(['fit' => [120, 120]])], 'Sample' => ['description' => 'A 400x400 sample, primarily used by the image-div class', 'slug' => 'sample', 'transforms' => json_encode(['fit' => [350, 350]])], 'Aerial Photo' => ['description' => 'A 530x260 image', 'slug' => 'aerial', 'transforms' => json_encode(['fit' => [530, 260]])], 'Aerial with Text' => ['description' => 'A 360x175 image with text in the bottom-left... not sure how we get the text yet', 'slug' => 'aerial-text', 'transforms' => json_encode(['fit' => [360, 175], 'borderText' => ['{{ imageable->name }}', 20, 150, ['file' => ['times.ttf'], 'size' => [40], 'color' => ['#ffffff']], '#000000', 1]])], 'Cropped' => ['description' => 'A 320xfull height image, cropping the sides', 'slug' => 'cropped', 'transforms' => json_encode(['fit' => [280, 240]])]]; for ($cols = 1; $cols <= 12; $cols++) { $px = 1200 * ($cols / 12 - 0.04); $profiles[$cols . ' Column'] = ['description' => 'A ' . $px . ' pixel wide image to match the width of ' . $cols . ' columns', 'slug' => $cols . 'col', 'transforms' => json_encode(['constrainFit' => [$px]])]; } foreach ($profiles as $profileName => $profileInfo) { if (ImageProfile::where('name', '=', $profileName)->first()) { continue; } $profile = new ImageProfile(['name' => $profileName, 'description' => $profileInfo['description'], 'slug' => $profileInfo['slug'], 'transforms' => $profileInfo['transforms']]); $profile->save(); } }
public function profile($profile) { if (!empty($profile)) { $image = $this->getInterventionObject(); $profile = ImageProfile::where('slug', '=', $profile)->first(); if ($profile) { $profile->applyTo($image, $this); } else { abort(404); } $this->cachedData = $image; } return $this; }