Dim intWidth,intHeight As Integer
Dim UlFileName,NewFileName As String
intWidth = 100 '*** Fix Width ***'
'intHeight = 0 '*** If = 0 Auto Re-Cal Size ***'
intHeight = 120
UlFileName = "MyImages/" & fiUpload.FileName
'*** Save Images ***'
Me.fiUpload.SaveAs(Server.MapPath(UlFileName))
NewFileName = "MyImages/Thumbnail_" & fiUpload.FileName
Dim objGraphic As System.Drawing.Image = System.Drawing.Image.FromFile(Server.MapPath(UlFileName))
Dim objBitmap As Bitmap
'*** Calculate Height ***'
If intHeight > 0 Then
objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
Else
If objGraphic.Width > intWidth Then
Dim ratio As Double = objGraphic.Height / objGraphic.Width
intHeight = ratio * intWidth
objBitmap = New Bitmap(objGraphic, intWidth, intHeight)
Else
objBitmap = New Bitmap(objGraphic)
End If
End If
'*** Save As ***'
objBitmap.Save(Server.MapPath(NewFileName), objGraphic.RawFormat)
'*** Close ***'
objGraphic.Dispose()