owner->width; $h = $this->owner->height; if (!($w && $h)) return false; $iWHRatio = $w/$h; $cWHRatio = $containerW/$containerH; // Default to 50% of available space $maxPixels = round($containerW*$containerH*$multiplier); // Scale to fill container if ($iWHRatio >= $cWHRatio) { $w = $containerW; $h = round($w/$iWHRatio); } else { $h = $containerH; $w = round($h*$iWHRatio); } // Scale down further if exceeds max space if ($w*$h > $maxPixels) { $w = round(sqrt($maxPixels * $iWHRatio)); $h = round($w / $iWHRatio); } if ($padX && $padY) return $this->owner->getFormattedImage('FramedImage', $w, $h, $frameW, $frameH); if ($padX) return $this->owner->getFormattedImage('FramedImage', $w, $h, $frameW, $h); if ($padY) return $this->owner->getFormattedImage('FramedImage', $w, $h, $w, $frameH); return $this->owner->isSize($w, $h) ? $this->owner : $this->owner->ResizedImage($w, $h); } /** * // ToDo Description * Use in templates with $ * * @param Image_Backend $backend * @param integer $ * @param integer $ * @return Image_Backend */ public function generateFramedImage(Image_Backend $backend, $imageW, $imageH, $frameW, $frameH, $backgroundColor = "FFFFFF"){ // Pad on both sides return $backend->resize($imageW, $imageH)->paddedResize($frameW, $imageH, $backgroundColor)->paddedResize($frameW, $frameH, $backgroundColor); } }