Conditions | 5 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function load(ImageInterface $image, array $options = array()) |
||
20 | { |
||
21 | if (!isset($options['min'])) { |
||
22 | throw new \InvalidArgumentException('Missing min option.'); |
||
23 | } |
||
24 | |||
25 | list($width, $height) = $options['min']; |
||
26 | |||
27 | $size = $image->getSize(); |
||
28 | $origWidth = $size->getWidth(); |
||
29 | $origHeight = $size->getHeight(); |
||
30 | |||
31 | if ($origWidth < $width || $origHeight < $height) { |
||
32 | $widthRatio = $width / $origWidth; |
||
33 | $heightRatio = $height / $origHeight; |
||
34 | |||
35 | $ratio = $widthRatio > $heightRatio ? $widthRatio : $heightRatio; |
||
36 | |||
37 | $filter = new Resize(new Box(round($origWidth * $ratio), round($origHeight * $ratio))); |
||
38 | |||
39 | return $filter->apply($image); |
||
40 | } |
||
41 | |||
42 | return $image; |
||
43 | } |
||
44 | } |
||
45 |