Neos\Media\Domain\Model\Adjustment\ResizeImageAdjustment::calculateDimensions PHP Method

calculateDimensions() protected method

Calculates and returns the dimensions the image should have according all parameters set in this adjustment.
protected calculateDimensions ( Imagine\Image\BoxInterface $originalDimensions ) : Imagine\Image\BoxInterface
$originalDimensions Imagine\Image\BoxInterface Dimensions of the unadjusted image
return Imagine\Image\BoxInterface
    protected function calculateDimensions(BoxInterface $originalDimensions)
    {
        $newDimensions = clone $originalDimensions;
        switch (true) {
            // height and width are set explicitly:
            case $this->width !== null && $this->height !== null:
                $newDimensions = $this->calculateWithFixedDimensions($originalDimensions, $this->width, $this->height);
                break;
                // only width is set explicitly:
            // only width is set explicitly:
            case $this->width !== null:
                $newDimensions = $this->calculateScalingToWidth($originalDimensions, $this->width);
                break;
                // only height is set explicitly:
            // only height is set explicitly:
            case $this->height !== null:
                $newDimensions = $this->calculateScalingToHeight($originalDimensions, $this->height);
                break;
        }
        // We apply maximum dimensions and scale the new dimensions proportionally down to fit into the maximum.
        if ($this->maximumWidth !== null && $newDimensions->getWidth() > $this->maximumWidth) {
            $newDimensions = $newDimensions->widen($this->maximumWidth);
        }
        if ($this->maximumHeight !== null && $newDimensions->getHeight() > $this->maximumHeight) {
            $newDimensions = $newDimensions->heighten($this->maximumHeight);
        }
        return $newDimensions;
    }