library/Garp/Image/Scaler.php
private function _getLeftUpperCoordinateOnCanvas($projectionWidth, $projectionHeight) {
        $canvasWidth = $this->_params['w'];
        $canvasHeight = $this->_params['h'];

        // Always center the projection horizontally.
        if ($projectionWidth > $canvasWidth) {
            $x = - (($projectionWidth / 2) - ($this->_params['w'] / 2));
        } else {
            $x = ($this->_params['w'] - $projectionWidth) / 2;
        }

        switch ($this->_params['cropfocus']) {
        case 'face':
            // If the image is taller than the canvas, move the starting point halfway up the center
            if ($projectionHeight > $canvasHeight) {
                $y = - ((($projectionHeight / 2) - ($this->_params['h'] / 2)) / 2);
            } else {
                $y = ($this->_params['h'] - $projectionHeight) / 2;
            }
            break;
        case 'center':
        default:
            //  center the projection vertically
            if ($projectionHeight > $canvasHeight) {
                $y = - (($projectionHeight / 2) - ($this->_params['h'] / 2));
            } else {
                $y = ($this->_params['h'] - $projectionHeight) / 2;
            }
        }
        return array($x, $y);
    }
private function _getLeftUpperCoordinateOnCanvas($projectionWidth, $projectionHeight) {
        $canvasWidth = $this->_params['w'];
        $canvasHeight = $this->_params['h'];

        // Always center the projection horizontally.
        if ($projectionWidth > $canvasWidth) {
            $x = - (($projectionWidth / 2) - ($this->_params['w'] / 2));
        } else {
            $x = ($this->_params['w'] - $projectionWidth) / 2;
        }

        switch ($this->_params['cropfocus']) {
        case 'face':
            // If the image is taller than the canvas, move the starting point halfway up the center
            if ($projectionHeight > $canvasHeight) {
                $y = - ((($projectionHeight / 2) - ($this->_params['h'] / 2)) / 2);
            } else {
                $y = ($this->_params['h'] - $projectionHeight) / 2;
            }
            break;
        case 'center':
        default:
            //  center the projection vertically
            if ($projectionHeight > $canvasHeight) {
                $y = - (($projectionHeight / 2) - ($this->_params['h'] / 2));
            } else {
                $y = ($this->_params['h'] - $projectionHeight) / 2;
            }
        }
        return array($x, $y);
    }
private function _getLeftUpperCoordinateOnCanvas ( $ projectionWidth , $ projectionHeight ) { $ canvasWidth = $ this -> _params [ 'w' ] ; $ canvasHeight = $ this -> _params [ 'h' ] ; // Always center the projection horizontally. if ( $ projectionWidth > $ canvasWidth ) { $ x = - ( ( $ projectionWidth / 2 ) - ( $ this -> _params [ 'w' ] / 2 ) ) ; } else { $ x = ( $ this -> _params [ 'w' ] - $ projectionWidth ) / 2 ; } switch ( $ this -> _params [ 'cropfocus' ] ) { case 'face' : // If the image is taller than the canvas, move the starting point halfway up the center if ( $ projectionHeight > $ canvasHeight ) { $ y = - ( ( ( $ projectionHeight / 2 ) - ( $ this -> _params [ 'h' ] / 2 ) ) / 2 ) ; } else { $ y = ( $ this -> _params [ 'h' ] - $ projectionHeight ) / 2 ; } break ; case 'center' : default : //  center the projection vertically if ( $ projectionHeight > $ canvasHeight ) { $ y = - ( ( $ projectionHeight / 2 ) - ( $ this -> _params [ 'h' ] / 2 ) ) ; } else { $ y = ( $ this -> _params [ 'h' ] - $ projectionHeight ) / 2 ; } } return array ( $ x , $ y ) ; }
Calculates the coordinates of the projection location on the canvas

@param int    $projectionWidth    Width of the projection
@param int    $projectionHeight   Height of the projection
@return array Numeric array, containing x- and y-coordinates of the upper left
point of the projection on the canvas
Calculates the coordinates of the projection location on the canvas