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;
}