PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 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 All 261 releases
wpfunnels / vendor / intervention / image / src / Intervention / Image / Imagick / Commands / FitCommand.php

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

43 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\Imagick\Commands;
4
5 use Intervention\Image\Commands\AbstractCommand;
6 use Intervention\Image\Size;
7
8 class FitCommand extends AbstractCommand
9 {
10 /**
11 * Crops and resized an image at the same time
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')->value($width);
20 $constraints = $this->argument(2)->type('closure')->value();
21 $position = $this->argument(3)->type('string')->value('center');
22
23 // calculate size
24 $cropped = $image->getSize()->fit(new Size($width, $height), $position);
25 $resized = clone $cropped;
26 $resized = $resized->resize($width, $height, $constraints);
27
28 // crop image
29 $image->getCore()->cropImage(
30 $cropped->width,
31 $cropped->height,
32 $cropped->pivot->x,
33 $cropped->pivot->y
34 );
35
36 // resize image
37 $image->getCore()->scaleImage($resized->getWidth(), $resized->getHeight());
38 $image->getCore()->setImagePage(0,0,0,0);
39
40 return true;
41 }
42 }
43