This example shows how to creating a thumbnail image from the an original file.
1
Creating the Bitmap

We will need a bitmap of the original file so we create it here.

[C#]

using (Image image = Bitmap.FromFile(Server.MapPath("rez/sora-sagano-8sOZJ8JF0S8-unsplash.jpg"))) {


2
Creating the image

We establish the thumbnail size as the original size width scaled to 120 pixels.

[C#]

  Size sz = image.Size * (120.0 / image.Width);


3
Drawing

We get the thumbnail bitmap.

[C#]

  using (Bitmap thumb = (Bitmap)image.GetThumbnailImage(sz.Width, sz.Height))


4
Saving

Finally we save the picture as a JPEG image.

[C#]

    thumb.Save(Server.MapPath("Making_Thumbnails_Easy_5.jpg"));
}


5
Input and Output

Sample input and output images are shown below.


sora-sagano-8sOZJ8JF0S8-unsplash.jpg


Making_Thumbnails_Easy_5.jpg