protected function calculateSize(array $params, array $imageSize) {
        if (empty($params['width']) && empty($params['height'])) {
            throw new TransformationException(
                'Missing both width and height. You need to specify at least one of them',
                400
            );
        }

        $width = !empty($params['width']) ? (int) $params['width'] : 0;
        $height = !empty($params['height']) ? (int) $params['height'] : 0;

        $originalWidth = $imageSize['width'];
        $originalHeight = $imageSize['height'];

        if ($width === $originalWidth && $height === $originalHeight) {
            // Resize params match the current image size, no need for any resizing
            return;
        }

        // Calculate width or height if not both have been specified
        if (!$height) {
            $height = ceil(($originalHeight / $originalWidth) * $width);
        } else if (!$width) {
            $width = ceil(($originalWidth / $originalHeight) * $height);
        }

        return ['width' => $width, 'height' => $height];
    }
protected function calculateSize(array $params, array $imageSize) {
        if (empty($params['width']) && empty($params['height'])) {
            throw new TransformationException(
                'Missing both width and height. You need to specify at least one of them',
                400
            );
        }

        $width = !empty($params['width']) ? (int) $params['width'] : 0;
        $height = !empty($params['height']) ? (int) $params['height'] : 0;

        $originalWidth = $imageSize['width'];
        $originalHeight = $imageSize['height'];

        if ($width === $originalWidth && $height === $originalHeight) {
            // Resize params match the current image size, no need for any resizing
            return;
        }

        // Calculate width or height if not both have been specified
        if (!$height) {
            $height = ceil(($originalHeight / $originalWidth) * $width);
        } else if (!$width) {
            $width = ceil(($originalWidth / $originalHeight) * $height);
        }

        return ['width' => $width, 'height' => $height];
    }
protected function calculateSize ( array $ params , array $ imageSize ) { if ( empty ( $ params [ 'width' ] ) && empty ( $ params [ 'height' ] ) ) { throw new TransformationException ( 'Missing both width and height. You need to specify at least one of them' , 400 ) ; } $ width = ! empty ( $ params [ 'width' ] ) ? ( int ) $ params [ 'width' ] : 0 ; $ height = ! empty ( $ params [ 'height' ] ) ? ( int ) $ params [ 'height' ] : 0 ; $ originalWidth = $ imageSize [ 'width' ] ; $ originalHeight = $ imageSize [ 'height' ] ; if ( $ width === $ originalWidth && $ height === $ originalHeight ) { // Resize params match the current image size, no need for any resizing return ; } // Calculate width or height if not both have been specified if ( ! $ height ) { $ height = ceil ( ( $ originalHeight / $ originalWidth ) * $ width ) ; } else if ( ! $ width ) { $ width = ceil ( ( $ originalWidth / $ originalHeight ) * $ height ) ; } return [ 'width' => $ width , 'height' => $ height ] ; }
Calculate output size of image

@param array $params
@param array $imageSize
@return array
Calculate output size of image