|
@@ 138-156 (lines=19) @@
|
| 135 |
|
$targetHeight = null; |
| 136 |
|
$targetX = null; |
| 137 |
|
$targetY = null; |
| 138 |
|
if ($width < $boxWidth && $height < $boxHeight && !$upsize) { |
| 139 |
|
$targetWidth = $width; |
| 140 |
|
$targetHeight = $height; |
| 141 |
|
$targetX = ($boxWidth - $width) / 2; |
| 142 |
|
$targetY = ($boxHeight - $height) / 2; |
| 143 |
|
} else { |
| 144 |
|
//if box is more vertical than original |
| 145 |
|
if ($boxRatio < $originalRatio) { |
| 146 |
|
$targetWidth = $boxWidth; |
| 147 |
|
$targetHeight = (int)((double)$boxWidth / $originalRatio); |
| 148 |
|
$targetX = 0; |
| 149 |
|
$targetY = ($boxHeight - $targetHeight) / 2; |
| 150 |
|
} else { |
| 151 |
|
$targetWidth = (int)((double)$boxHeight * $originalRatio); |
| 152 |
|
$targetHeight = $boxHeight; |
| 153 |
|
$targetX = ($boxWidth - $targetWidth) / 2; |
| 154 |
|
$targetY = 0; |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
//do iterative downsize by halfs (2x2 binning is a common name) on dimensions that are bigger than target |
| 159 |
|
//width and height |
|
@@ 325-343 (lines=19) @@
|
| 322 |
|
$targetHeight = null; |
| 323 |
|
$targetX = null; |
| 324 |
|
$targetY = null; |
| 325 |
|
if ($width < $boxWidth && $height < $boxHeight && !$upsize) { |
| 326 |
|
$targetWidth = $width; |
| 327 |
|
$targetHeight = $height; |
| 328 |
|
$targetX = ($boxWidth - $width) / 2; |
| 329 |
|
$targetY = ($boxHeight - $height) / 2; |
| 330 |
|
} else { |
| 331 |
|
//if box is more vertical than original |
| 332 |
|
if ($boxRatio < $originalRatio) { |
| 333 |
|
$targetWidth = $boxWidth; |
| 334 |
|
$targetHeight = (int)((double)$boxWidth / $originalRatio); |
| 335 |
|
$targetX = 0; |
| 336 |
|
$targetY = ($boxHeight - $targetHeight) / 2; |
| 337 |
|
} else { |
| 338 |
|
$targetWidth = (int)((double)$boxHeight * $originalRatio); |
| 339 |
|
$targetHeight = $boxHeight; |
| 340 |
|
$targetX = ($boxWidth - $targetWidth) / 2; |
| 341 |
|
$targetY = 0; |
| 342 |
|
} |
| 343 |
|
} |
| 344 |
|
|
| 345 |
|
//do iterative downsize by halfs (2x2 binning is a common name) on dimensions that are bigger than target |
| 346 |
|
//width and height |