+
+ } else if ( isset($requestEnv['width']) && isset($requestEnv['height']) ) {
+ // proportional scaling within requested width/height
+ $srcAspect = floatval($imageInfo['width']) / floatval($imageInfo['height']);
+ $fitAspect = floatval($requestEnv['width']) / floatval($requestEnv['height']);
+
+ if ($srcAspect > $fitAspect) {
+ // Source image is wide compared to fit
+ $powReduce = $this->nearestPow2Reduce($requestEnv['width'], $imageInfo['width']);
+ } else {
+ $powReduce = $this->nearestPow2Reduce($requestEnv['height'], $imageInfo['height']);
+ }
+ $scale = pow(2, $poweReduce);
+
+ } else if ( isset($requestEnv['width']) ) {
+ // Fit within width
+ $powReduce = $this->nearestPow2Reduce($requestEnv['width'], $imageInfo['width']);
+ $scale = pow(2, $powReduce);
+
+ } else if ( isset($requestEnv['height'])) {
+ // Fit within height
+ $powReduce = $this->nearestPow2Reduce($requestEnv['height'], $imageInfo['height']);
+ $scale = pow(2, $powReduce);