| Conditions | 2 |
| Paths | 2 |
| Total Lines | 26 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 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) { |
||
| 32 | $ratio = 1; |
||
| 33 | } |
||
| 34 | |||
| 35 | // Define sizes |
||
| 36 | $this->_destWidth = floor($originalWidth * $ratio); |
||
| 37 | $this->_destHeight = floor($originalHeight * $ratio); |
||
| 38 | |||
| 39 | // Define margins |
||
| 40 | $this->_destX = floor(($this->_width - $this->_destWidth) / 2); |
||
| 41 | $this->_destY = floor(($this->_height - $this->_destHeight) / 2); |
||
| 42 | |||
| 43 | // Execute the Crop method with the given parameters |
||
| 44 | return parent::Execute($imageResource); |
||
| 45 | } |
||
| 47 | } |