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