| // +---------------------------------------------------------------------------+ /** * Strategy for resizing canvas. * * @package SGL * @author Dmitri Lakachauskis */ class SGL_ImageTransform_CanvasResizeStrategy extends SGL_ImageTransformStrategy { function transform() { $width = null; $height = null; if (isset($this->aParams['width'])) { $width = $this->aParams['width']; } if (isset($this->aParams['height'])) { $height = $this->aParams['height']; } $aSize = $this->driver->getImageSize(); $resultX = $aSize[0]; $resultY = $aSize[1]; if (isset($width) && $width > $aSize[0]) { $resultX = $width; } if (isset($height) && $height > $aSize[1]) { $resultY = $height; } if ($aSize[0] == $resultX && $aSize[1] == $resultY) { // canvas size must be wider, do not apply resizing return false; } $aDefaultParams = array( 'position' => 'center', 'color' => 'white' ); $aParams = array_merge($aDefaultParams, $this->aParams); return $this->driver->canvasResize($resultX, $resultY, $aParams['position'], $aParams['color']); } } ?>