Code to Resize Image in ASP.Net>
This code is use to convert an Images with different sizes.
sometimes it needs to create one image in number of different sizes/resolutions to upload.
It requires more time.
This code will help to create different images from one in different resolutions without disturbing the clearity.
Below is the code to resize an Image of any format in asp.net.
'Mention the Width of image you have to generate
Dim width = "Width of Destination Image"
'Mention the height of image you have to generate
Dim height = "Height of Destination Image"
'operator to seperate width and height
Dim mult = "x"
Dim ImageName = "Enter Name Of Image"
'mention the format of destination image ie. .jpg,.gif,bmp etc
Dim format = "File Format"
'mention the path Where source image is located
Dim src As String = "Source Path (Where image is located)"
'Response.Write("src=" & src)
'mention the path Where destination image is located
Dim dest As String = "Destination Path (Where u want to save new image"
'Response.Write("dest=" & dest)
Dim thumbWidth As Integer = width
Dim thumbHeight As Integer = height
'Convertion code is starts here
Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(src)
Dim srcWidth As Integer = image.Width
Dim srcHeight As Integer = image.Height
Dim sizeRatio As Decimal = (CDec(srcHeight) / srcWidth)
Dim bmp As New Bitmap(thumbWidth, thumbHeight)
Dim gr As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmp)
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High
Dim rectDestination As New System.Drawing.Rectangle(0, 0, thumbWidth, thumbHeight)
gr.DrawImage(image, rectDestination, 0, 0, srcWidth, srcHeight, _
'Convertion code is ends here
MessageBox.Show("Resize Image stored at" & dest)
Please format your resource.