private static function enforceMaxSize($width, $height, $originalSize, $maintainAspect, $zoomFactor = 1.0): array
    {
        $adjustedWidth = $width;
        $adjustedHeight = $height;

        if ($adjustedWidth > $originalSize->getWidth() * $zoomFactor) {
            $adjustedWidth = floor($originalSize->getWidth() * $zoomFactor);

            if ($maintainAspect) {
                $adjustedHeight = floor($height * ($adjustedWidth / $width));
            }
        }

        if ($adjustedHeight > $originalSize->getHeight() * $zoomFactor) {
            $adjustedHeight = floor($originalSize->getHeight() * $zoomFactor);

            if ($maintainAspect) {
                $adjustedWidth = floor($width * ($adjustedHeight / $height));
            }
        }

        return [$adjustedWidth, $adjustedHeight];
    }
private static function enforceMaxSize($width, $height, $originalSize, $maintainAspect, $zoomFactor = 1.0): array
    {
        $adjustedWidth = $width;
        $adjustedHeight = $height;

        if ($adjustedWidth > $originalSize->getWidth() * $zoomFactor) {
            $adjustedWidth = floor($originalSize->getWidth() * $zoomFactor);

            if ($maintainAspect) {
                $adjustedHeight = floor($height * ($adjustedWidth / $width));
            }
        }

        if ($adjustedHeight > $originalSize->getHeight() * $zoomFactor) {
            $adjustedHeight = floor($originalSize->getHeight() * $zoomFactor);

            if ($maintainAspect) {
                $adjustedWidth = floor($width * ($adjustedHeight / $height));
            }
        }

        return [$adjustedWidth, $adjustedHeight];
    }
private static function enforceMaxSize ( $ width , $ height , $ originalSize , $ maintainAspect , $ zoomFactor = 1.0 ) : array { $ adjustedWidth = $ width ; $ adjustedHeight = $ height ; if ( $ adjustedWidth > $ originalSize -> getWidth ( ) * $ zoomFactor ) { $ adjustedWidth = floor ( $ originalSize -> getWidth ( ) * $ zoomFactor ) ; if ( $ maintainAspect ) { $ adjustedHeight = floor ( $ height * ( $ adjustedWidth / $ width ) ) ; } } if ( $ adjustedHeight > $ originalSize -> getHeight ( ) * $ zoomFactor ) { $ adjustedHeight = floor ( $ originalSize -> getHeight ( ) * $ zoomFactor ) ; if ( $ maintainAspect ) { $ adjustedWidth = floor ( $ width * ( $ adjustedHeight / $ height ) ) ; } } return [ $ adjustedWidth , $ adjustedHeight ] ; }
Enforces a max size if allowUpscale is false

@param int $width
@param int $height
@param BoxInterface $originalSize
@param bool $maintainAspect
@param float $zoomFactor

@return array
Enforces a max size if allowUpscale is false