src/Silvestra/Component/Media/Image/Resizer/ImageResizerHelper.php
public function getImageSizeInBox(array $imageSize, array $boxSize)
    {
        list($imageWidth, $imageHeight) = $imageSize;
        list($boxWidth, $boxHeight) = $boxSize;

        if (($imageWidth <= $boxWidth) && ($imageHeight <= $boxHeight)) {
            return $imageSize;
        }

        $resizeRatio = min($boxWidth / $imageWidth, $boxHeight / $imageHeight);

        $imageWidth = ceil($imageWidth * $resizeRatio);

        if ($imageWidth > $boxWidth) {
            $imageWidth = $boxWidth;
        }

        $imageHeight = ceil($imageHeight * $resizeRatio);

        if ($imageHeight > $boxHeight) {
            $imageHeight = $boxHeight;
        }

        return array($imageWidth, $imageHeight);
    }
public function getImageSizeInBox(array $imageSize, array $boxSize)
    {
        list($imageWidth, $imageHeight) = $imageSize;
        list($boxWidth, $boxHeight) = $boxSize;

        if (($imageWidth <= $boxWidth) && ($imageHeight <= $boxHeight)) {
            return $imageSize;
        }

        $resizeRatio = min($boxWidth / $imageWidth, $boxHeight / $imageHeight);

        $imageWidth = ceil($imageWidth * $resizeRatio);

        if ($imageWidth > $boxWidth) {
            $imageWidth = $boxWidth;
        }

        $imageHeight = ceil($imageHeight * $resizeRatio);

        if ($imageHeight > $boxHeight) {
            $imageHeight = $boxHeight;
        }

        return array($imageWidth, $imageHeight);
    }
public function getImageSizeInBox ( array $ imageSize , array $ boxSize ) { list ( $ imageWidth , $ imageHeight ) = $ imageSize ; list ( $ boxWidth , $ boxHeight ) = $ boxSize ; if ( ( $ imageWidth <= $ boxWidth ) && ( $ imageHeight <= $ boxHeight ) ) { return $ imageSize ; } $ resizeRatio = min ( $ boxWidth / $ imageWidth , $ boxHeight / $ imageHeight ) ; $ imageWidth = ceil ( $ imageWidth * $ resizeRatio ) ; if ( $ imageWidth > $ boxWidth ) { $ imageWidth = $ boxWidth ; } $ imageHeight = ceil ( $ imageHeight * $ resizeRatio ) ; if ( $ imageHeight > $ boxHeight ) { $ imageHeight = $ boxHeight ; } return array ( $ imageWidth , $ imageHeight ) ; }
Get image size in box.

@param array $imageSize
@param array $boxSize

@return array
Get image size in box .