How to resize an image in asp.net

To resize an image use the following code

where imgHeight and imgWidth is what you want to image to be


                    Dim oImg As System.Drawing.Image = System.Drawing.Image.FromStream(fileUpload.PostedFile.InputStream)
                    Dim oResized As System.Drawing.Image = New Bitmap(imgWidth, imgHeight)
                    Dim oGraphic As Graphics = Graphics.FromImage(oResized)
                    oGraphic.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
                    oGraphic.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
                    oGraphic.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                    Dim oRectangle As Rectangle = New Rectangle(0, 0, imgWidth, imgHeight)
                    oGraphic.DrawImage(oImg, oRectangle)
                    oResized.Save(actualPath & fileName & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
                    oImg.Dispose()