/// <Summary>
/// Method for obtaining proportional scaling Images
/// </Summary>
/// <Param name = "imgPath"> image path to be scaled </param>
/// <Param name = "savePath"> resize the image storage path </param>
/// <Param name = "format"> resize the image storage format </param>
/// <Param name = "scaling"> width or height to be kept </param>
/// <Param name = "keepWidthOrHeight"> if it is true, the width is scaling; otherwise, the height is scaling. </param>
/// <Returns> </returns>
Public bool GetThumbnail (string imgPath, string savePath, ImageFormat format, int scaling, bool keepWidthOrHeight)
{
Try
{
Using (Bitmap myBitmap = new Bitmap (imgPath ))
{
Int width = 0;
Int height = 0;
Int tw = myBitmap. Width; // The actual Width of the image.
Int th = myBitmap. Height; // The actual Height of the image
If (keepWidthOrHeight) // keep the width
{
# Region auto-retain width
If (scaling> = tw)
{
Width = tw;
Height = th;
}
Else
{
Double ti = Convert. ToDouble (tw)/Convert. ToDouble (scaling );
If (ti = 0d)
{
Width = tw;
Height = th;
}
Else
{
Width = scaling;
Height = Convert. ToInt32 (Convert. ToDouble (th)/ti );
}
}
# Endregion
}
& Nb