protected function calculateSize(array $params, array $imageSize) {
        $maxWidth = !empty($params['width']) ? (int) $params['width'] : 0;
        $maxHeight = !empty($params['height']) ? (int) $params['height'] : 0;

        $sourceWidth  = $imageSize['width'];
        $sourceHeight = $imageSize['height'];

        $width  = $maxWidth  ?: $sourceWidth;
        $height = $maxHeight ?: $sourceHeight;

        // Figure out original ratio
        $ratio = $sourceWidth / $sourceHeight;

        if (($width / $height) > $ratio) {
            $width  = round($height * $ratio);
        } else {
            $height = round($width / $ratio);
        }

        // Is the original image smaller than the specified parameters?
        if ($sourceWidth <= $width && $sourceHeight <= $height) {
            // Original image is smaller than the max-parameters, don't transform
            return;
        }

        return ['width' => $width, 'height' => $height];
    }
protected function calculateSize(array $params, array $imageSize) {
        $maxWidth = !empty($params['width']) ? (int) $params['width'] : 0;
        $maxHeight = !empty($params['height']) ? (int) $params['height'] : 0;

        $sourceWidth  = $imageSize['width'];
        $sourceHeight = $imageSize['height'];

        $width  = $maxWidth  ?: $sourceWidth;
        $height = $maxHeight ?: $sourceHeight;

        // Figure out original ratio
        $ratio = $sourceWidth / $sourceHeight;

        if (($width / $height) > $ratio) {
            $width  = round($height * $ratio);
        } else {
            $height = round($width / $ratio);
        }

        // Is the original image smaller than the specified parameters?
        if ($sourceWidth <= $width && $sourceHeight <= $height) {
            // Original image is smaller than the max-parameters, don't transform
            return;
        }

        return ['width' => $width, 'height' => $height];
    }
protected function calculateSize ( array $ params , array $ imageSize ) { $ maxWidth = ! empty ( $ params [ 'width' ] ) ? ( int ) $ params [ 'width' ] : 0 ; $ maxHeight = ! empty ( $ params [ 'height' ] ) ? ( int ) $ params [ 'height' ] : 0 ; $ sourceWidth = $ imageSize [ 'width' ] ; $ sourceHeight = $ imageSize [ 'height' ] ; $ width = $ maxWidth ? : $ sourceWidth ; $ height = $ maxHeight ? : $ sourceHeight ; // Figure out original ratio $ ratio = $ sourceWidth / $ sourceHeight ; if ( ( $ width / $ height ) > $ ratio ) { $ width = round ( $ height * $ ratio ) ; } else { $ height = round ( $ width / $ ratio ) ; } // Is the original image smaller than the specified parameters? if ( $ sourceWidth <= $ width && $ sourceHeight <= $ height ) { // Original image is smaller than the max-parameters, don't transform return ; } return [ 'width' => $ width , 'height' => $ height ] ; }
Calculate the output size based on the specified parameters

@param array $params
@param array $imageSize
@return array|boolean
Calculate the output size based on the specified parameters