Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

ScalePercentFilterLoader.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader;
8
9 use Imagine\Image\ImageInterface;
10 use Imagine\Exception\InvalidArgumentException;
11
16 class ScalePercentFilterLoader extends FilterLoaderWrapped
17 {
18 public function load(ImageInterface $image, array $options = [])
19 {
20 if (count($options) < 2) {
21 throw new InvalidArgumentException('Missing width and/or height percent options');
22 }
23
24 $size = $image->getSize();
25 $origWidth = $size->getWidth();
26 $origHeight = $size->getHeight();
27 list($widthPercent, $heightPercent) = $options;
28
29 $targetWidth = ($origWidth * $widthPercent) / 100;
30 $targetHeight = ($origHeight * $heightPercent) / 100;
31
32 return $this->innerLoader->load($image, ['size' => [$targetWidth, $targetHeight]]);
33 }
34 }
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\FilterLoaderWrapped
Definition: FilterLoaderWrapped.php:12
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\ScalePercentFilterLoader
Filter loader for geometry/scaleexact filter.
Definition: ScalePercentFilterLoader.php:17
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader\ScalePercentFilterLoader\load
load(ImageInterface $image, array $options=[])
Definition: ScalePercentFilterLoader.php:18
eZ\Bundle\EzPublishCoreBundle\Imagine\Filter\Loader
Definition: BorderFilterLoader.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.