Internal function that determines when to resize by width or height in a Image Resizer utility Description:

Given an image X with known dimensions. We call a method CreateThumbnail to make a thumbnail (or not) with a given max-width and max-height (both optional).

CreateThumbnail call ComputeSize method (bad name?) which is responsable for doing the following logic:

If no max-width/max-height, the width and height should return as is.
If only one is provided, then we call a method ResizeWidth on the Dimention2D object to return a new dimension based on the new width size (aspectRation is kept).

Same applies for height.

If both are provided, use the one, that while keeping the aspect ration, won't be bigger than their corresponding maximum.

If the image dimension are smaller than the maximum, no change to the dimensions.

Then, with the new size, the Resize is actually applied (or not) (this is outside the scope of this method).

private Dimention2D ComputeSize(Image image, int maxWidth, int maxHeight)
{
    if (image == null) throw new ArgumentNullException(nameof(image));
    var sourceDimension = new Dimention2D(image.Width, image.Height);

        bool computeWidth = maxWidth &gt; 0 &amp;&amp; sourceDimension.Width &gt; maxWidth;
        bool computeHeight = maxHeight &gt; 0 &amp;&amp; sourceDimension.Height &gt; maxHeight;

    if (computeWidth &amp;&amp; computeHeight)
    {
        if (sourceDimension.Width / maxWidth &gt; sourceDimension.Height / maxHeight)
            computeHeight = false;
        else
            computeWidth = false;
    }

    if (computeWidth)
        return sourceDimension.ResizeWidth(maxWidth);

    else if (computeHeight)
        return sourceDimension.ResizeHeight(maxHeight);

    else return sourceDimension;
}


I'm open to any suggestion.
Variables/methods names, the use (or lack of) { and } on if/else, the if/else. and whatever thing you can think of making it prettier.
You can replace this:

if (computeWidth)
    return sourceDimension.ResizeWidth(maxWidth);

else if (computeHeight)
    return sourceDimension.ResizeHeight(maxHeight);

else return sourceDimension;


with this:

if (computeWidth)
    return sourceDimension.ResizeWidth(maxWidth);
if (computeHeight)
    return sourceDimension.ResizeHeight(maxHeight);
return sourceDimension;


I would rename the method and input parameters, as it would add more sense to the method name and input parameters.

private Dimention2D  ReSize(Image image, int requireWidth, int requireHeight);