Neos\Media\Domain\Model\Adjustment\ResizeImageAdjustment::calculateOutboundBox PHP Méthode

calculateOutboundBox() protected méthode

Calculate the final dimensions for an outbound box. usually exactly the requested width and height unless that would require upscaling and it is not allowed.
protected calculateOutboundBox ( Imagine\Image\BoxInterface $originalDimensions, integer $requestedWidth, integer $requestedHeight ) : Imagine\Image\BoxInterface
$originalDimensions Imagine\Image\BoxInterface
$requestedWidth integer
$requestedHeight integer
Résultat Imagine\Image\BoxInterface
    protected function calculateOutboundBox(BoxInterface $originalDimensions, $requestedWidth, $requestedHeight)
    {
        $newDimensions = new Box($requestedWidth, $requestedHeight);
        if ($this->getAllowUpScaling() === true || $originalDimensions->contains($newDimensions) === true) {
            return $newDimensions;
        }
        // We need to make sure that the new dimensions are such that no upscaling is needed.
        $ratios = array($originalDimensions->getWidth() / $requestedWidth, $originalDimensions->getHeight() / $requestedHeight);
        $ratio = min($ratios);
        $newDimensions = $newDimensions->scale($ratio);
        return $newDimensions;
    }