I have following markup codes that has a container div element and an img tag nested inside the div. The container div has width, height, top and left CSS style properties. 

An originally uploaded image has arbitrary width and height that may be bigger or smaller than the container div. So definitely, the originally uploaded image must be resized and well scaled, and saved as an thumbnail image to sit within the borders of the container div. That resized thumbnail image will be shown as the source (src) in the following markups:

```
<div id="divContainer" style="width: 600px; height: 450px; top: 50px; left: 20px;">
   <img src="[my resized and well scaled thumbnail source]..." id="imgResizedThumnail" />
</div>

```

In a another .NET form page, there is a file tag letting users upload an original image from local hard disk. That uploaded image needs to be resized and saved as another thumbnail image with best scaling. "Best scalling" means the thumbnail image has a proportional ratio of width and height, and the thumbnail must be sit within the container div.

My C# .NET method looks like follows and I have questions about the code logic in that method.

...

```
using System.Drawing;

public void SaveThumbnailImageWithbestScaling(Image originalImage, int containerDivWidth, int containerDivHeight)
{
     // input containerDivWidth and containerDivHeight are dynamic!
     // 1. How can I calculate the scale variable?  
     double scale = ??? // how can I do the codes here?

     // 2. Use that scale to determine the dimension of resized thumbnail image from       
     // the input originalImage for following variables "thumnailWidth" and "thumnailHeight"    

     string thumbnailFilename = "myThumnailFileName";
     int thumnailWidth = ???  // how can I do the codes here?
     int thumnailHeight = ??? // how can I do the codes here?

     Bitmap thumnailImage = CreateThumbnail(thumbnailFilename,int thumnailWidth, int thumnailHeight);

     // 3. save thumbnail
     SaveThumnail(thumnailImage);   
}

public void Bitmap CreateThumbnail(string lcFilename,int lnWidth, int lnHeight)
{
    ...
}

public void thumnailImage (Bitmap thumnail)
{
   ...
}

```