PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.1
3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 2.8.17 2.8.18 All 259 releases
wpfunnels / vendor / intervention / image / src / Intervention / Image / Gd / Commands / CropCommand.php

CropCommand.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.1, at vendor/intervention/image/src/Intervention/Image/Gd/Commands/CropCommand.php

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\Image\Gd\Commands;
4
5 use Intervention\Image\Point;
6 use Intervention\Image\Size;
7
8 class CropCommand extends ResizeCommand
9 {
10 /**
11 * Crop an image instance
12 *
13 * @param \Intervention\Image\Image $image
14 * @return boolean
15 */
16 public function execute($image)
17 {
18 $width = $this->argument(0)->type('digit')->required()->value();
19 $height = $this->argument(1)->type('digit')->required()->value();
20 $x = $this->argument(2)->type('digit')->value();
21 $y = $this->argument(3)->type('digit')->value();
22
23 if (is_null($width) || is_null($height)) {
24 throw new \Intervention\Image\Exception\InvalidArgumentException(
25 "Width and height of cutout needs to be defined."
26 );
27 }
28
29 $cropped = new Size($width, $height);
30 $position = new Point($x, $y);
31
32 // align boxes
33 if (is_null($x) && is_null($y)) {
34 $position = $image->getSize()->align('center')->relativePosition($cropped->align('center'));
35 }
36
37 // crop image core
38 return $this->modify($image, 0, 0, $position->x, $position->y, $cropped->width, $cropped->height, $cropped->width, $cropped->height);
39 }
40 }
41