Conditions | 2 |
Paths | 2 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
19 | public function Execute($imageResource) |
||
20 | { |
||
21 | // Define the origial width and height |
||
22 | $originalWidth = imagesx($imageResource); |
||
23 | $originalHeight = imagesy($imageResource); |
||
24 | |||
25 | // Define the ratios |
||
26 | $wRatio = $this->_width / $originalWidth; |
||
27 | $hRatio = $this->_height / $originalHeight; |
||
28 | |||
29 | // Define which ratio will be used, depending on which is the smallest side |
||
30 | $ratio = min($hRatio, $wRatio); |
||
31 | if($ratio > 1) $ratio = 1; |
||
32 | |||
33 | // Define sizes |
||
34 | $this->_destWidth = floor($originalWidth * $ratio); |
||
35 | $this->_destHeight = floor($originalHeight * $ratio); |
||
36 | |||
37 | // Define margins |
||
38 | $this->_destX = floor(($this->_width - $this->_destWidth) / 2); |
||
39 | $this->_destY = floor(($this->_height - $this->_destHeight) / 2); |
||
40 | |||
41 | // Execute the Crop method with the given parameters |
||
42 | return parent::Execute($imageResource); |
||
43 | } |
||
44 | } |
||
45 | } |