| @@ 5-26 (lines=22) @@ | ||
| 2 | ||
| 3 | use Modules\Media\Image\ImageHandlerInterface; |
|
| 4 | ||
| 5 | class Crop implements ImageHandlerInterface |
|
| 6 | { |
|
| 7 | private $defaults = [ |
|
| 8 | 'width' => '100', |
|
| 9 | 'height' => '100', |
|
| 10 | 'x' => null, |
|
| 11 | 'y' => null, |
|
| 12 | ]; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * Handle the image manipulation request |
|
| 16 | * @param \Intervention\Image\Image $image |
|
| 17 | * @param array $options |
|
| 18 | * @return mixed |
|
| 19 | */ |
|
| 20 | public function handle($image, $options) |
|
| 21 | { |
|
| 22 | $options = array_merge($this->defaults, $options); |
|
| 23 | ||
| 24 | return $image->crop($options['width'], $options['height'], $options['x'], $options['y']); |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||
| @@ 5-26 (lines=22) @@ | ||
| 2 | ||
| 3 | use Modules\Media\Image\ImageHandlerInterface; |
|
| 4 | ||
| 5 | class Watermark implements ImageHandlerInterface |
|
| 6 | { |
|
| 7 | private $defaults = [ |
|
| 8 | 'source' => 'public/assets/watermark.png', |
|
| 9 | 'position' => 'bottom-right', |
|
| 10 | 'x' => null, |
|
| 11 | 'y' => null, |
|
| 12 | ]; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * Handle the image manipulation request |
|
| 16 | * @param \Intervention\Image\Image $image |
|
| 17 | * @param array $options |
|
| 18 | * @return \Intervention\Image\Image |
|
| 19 | */ |
|
| 20 | public function handle($image, $options) |
|
| 21 | { |
|
| 22 | $options = array_merge($this->defaults, $options); |
|
| 23 | ||
| 24 | return $image->insert($options['source'], $options['position'], $options['x'], $options['y']); |
|
| 25 | } |
|
| 26 | } |
|
| 27 | ||