private function getCropPoints($optimalWidth, $optimalHeight, $newWidth, $newHeight)
        {
            $cropPoints = array();

            $vertical_start = arrayGet($this->config, 'crop_vertical_start_point');
            $horizontal_start = arrayGet($this->config, 'crop_horizontal_start_point');

            // Where is our vertical starting crop point?
            switch ($vertical_start) {
                case 'top':
                    $cropPoints['y'] = 0;
                    break;
                case 'center':
                    $cropPoints['y'] = ($optimalHeight / 2) - ($newHeight / 2);
                    break;
                case 'bottom':
                    $cropPoints['y'] = $optimalHeight - $newHeight;
                    break;

                default:
                    throw new Exception('Unknown value for crop_vertical_start_point: '. $vertical_start .'. Please check config file in the Resizer bundle.');
                    break;
            }

            // Where is our horizontal starting crop point?
            switch ($horizontal_start) {
                case 'left':
                    $cropPoints['x'] = 0;
                    break;
                case 'center':
                    $cropPoints['x'] = ($optimalWidth / 2) - ($newWidth / 2);
                    break;
                case 'right':
                    $cropPoints['x'] = $optimalWidth - $newWidth;
                    break;

                default:
                    throw new Exception('Unknown value for crop_horizontal_start_point: '. $horizontal_start .'. Please check config file in the Resizer bundle.');
                    break;
            }

            return $cropPoints;
        }
private function getCropPoints($optimalWidth, $optimalHeight, $newWidth, $newHeight)
        {
            $cropPoints = array();

            $vertical_start = arrayGet($this->config, 'crop_vertical_start_point');
            $horizontal_start = arrayGet($this->config, 'crop_horizontal_start_point');

            // Where is our vertical starting crop point?
            switch ($vertical_start) {
                case 'top':
                    $cropPoints['y'] = 0;
                    break;
                case 'center':
                    $cropPoints['y'] = ($optimalHeight / 2) - ($newHeight / 2);
                    break;
                case 'bottom':
                    $cropPoints['y'] = $optimalHeight - $newHeight;
                    break;

                default:
                    throw new Exception('Unknown value for crop_vertical_start_point: '. $vertical_start .'. Please check config file in the Resizer bundle.');
                    break;
            }

            // Where is our horizontal starting crop point?
            switch ($horizontal_start) {
                case 'left':
                    $cropPoints['x'] = 0;
                    break;
                case 'center':
                    $cropPoints['x'] = ($optimalWidth / 2) - ($newWidth / 2);
                    break;
                case 'right':
                    $cropPoints['x'] = $optimalWidth - $newWidth;
                    break;

                default:
                    throw new Exception('Unknown value for crop_horizontal_start_point: '. $horizontal_start .'. Please check config file in the Resizer bundle.');
                    break;
            }

            return $cropPoints;
        }
private function getCropPoints ( $ optimalWidth , $ optimalHeight , $ newWidth , $ newHeight ) { $ cropPoints = array ( ) ; $ vertical_start = arrayGet ( $ this -> config , 'crop_vertical_start_point' ) ; $ horizontal_start = arrayGet ( $ this -> config , 'crop_horizontal_start_point' ) ; // Where is our vertical starting crop point? switch ( $ vertical_start ) { case 'top' : $ cropPoints [ 'y' ] = 0 ; break ; case 'center' : $ cropPoints [ 'y' ] = ( $ optimalHeight / 2 ) - ( $ newHeight / 2 ) ; break ; case 'bottom' : $ cropPoints [ 'y' ] = $ optimalHeight - $ newHeight ; break ; default : throw new Exception ( 'Unknown value for crop_vertical_start_point: ' . $ vertical_start . '. Please check config file in the Resizer bundle.' ) ; break ; } // Where is our horizontal starting crop point? switch ( $ horizontal_start ) { case 'left' : $ cropPoints [ 'x' ] = 0 ; break ; case 'center' : $ cropPoints [ 'x' ] = ( $ optimalWidth / 2 ) - ( $ newWidth / 2 ) ; break ; case 'right' : $ cropPoints [ 'x' ] = $ optimalWidth - $ newWidth ; break ; default : throw new Exception ( 'Unknown value for crop_horizontal_start_point: ' . $ horizontal_start . '. Please check config file in the Resizer bundle.' ) ; break ; } return $ cropPoints ; }
Gets the crop points based on the configuration either set in the file
or overridden by user in their own config file, or on the fly.
@param  int    $optimalWidth  The width of the image
@param  int    $optimalHeight The height of the image
@param  int    $newWidth      The new width
@param  int    $newHeight     The new height
@return array                  Array containing the crop x and y points.
Gets the crop points based on the configuration either set in the file or overridden by user in their own config file or on the fly .