Neos.Media/Classes/Domain/Model/Adjustment/CropImageAdjustment.php
public static function calculateDimensionsByAspectRatio(int $originalWidth, int $originalHeight, AspectRatio $desiredAspectRatio): array
    {
        $newWidth = $originalWidth;
        $newHeight = round($originalWidth / $desiredAspectRatio->getRatio());
        $newX = 0;
        $newY = round(($originalHeight - $newHeight) / 2);

        if ($newHeight > $originalHeight) {
            $newHeight = $originalHeight;
            $newY = 0;
            $newWidth = round($originalHeight * $desiredAspectRatio->getRatio());
            $newX = round(($originalWidth - $newWidth) / 2);
        }

        return [$newX, $newY, $newWidth, $newHeight];
    }
public static function calculateDimensionsByAspectRatio(int $originalWidth, int $originalHeight, AspectRatio $desiredAspectRatio): array
    {
        $newWidth = $originalWidth;
        $newHeight = round($originalWidth / $desiredAspectRatio->getRatio());
        $newX = 0;
        $newY = round(($originalHeight - $newHeight) / 2);

        if ($newHeight > $originalHeight) {
            $newHeight = $originalHeight;
            $newY = 0;
            $newWidth = round($originalHeight * $desiredAspectRatio->getRatio());
            $newX = round(($originalWidth - $newWidth) / 2);
        }

        return [$newX, $newY, $newWidth, $newHeight];
    }
public static function calculateDimensionsByAspectRatio ( int $ originalWidth , int $ originalHeight , AspectRatio $ desiredAspectRatio ) : array { $ newWidth = $ originalWidth ; $ newHeight = round ( $ originalWidth / $ desiredAspectRatio -> getRatio ( ) ) ; $ newX = 0 ; $ newY = round ( ( $ originalHeight - $ newHeight ) / 2 ) ; if ( $ newHeight > $ originalHeight ) { $ newHeight = $ originalHeight ; $ newY = 0 ; $ newWidth = round ( $ originalHeight * $ desiredAspectRatio -> getRatio ( ) ) ; $ newX = round ( ( $ originalWidth - $ newWidth ) / 2 ) ; } return [ $ newX , $ newY , $ newWidth , $ newHeight ] ; }
Calculates the actual position and dimensions of the cropping area based on the given image
dimensions and desired aspect ratio.

@param int $originalWidth Width of the original image
@param int $originalHeight Height of the original image
@param AspectRatio $desiredAspectRatio The desired aspect ratio
@return array Returns an array containing x, y, width and height
Calculates the actual position and dimensions of the cropping area based on the given image dimensions and desired aspect ratio .