This is a migrated thread and some comments may be shown as answers.

Change dimension image uploaded

2 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fabio Cirillo
Top achievements
Rank 1
Fabio Cirillo asked on 19 Feb 2013, 02:05 PM
is possible before or after uploading an image, change its dimensions?
Why I load the images into a div via css and I set the background-size, it works on all browsers except on IE8. Here the image does not change size. So I was thinking that it was better to directly change the size of the uploaded file. How can I do?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Feb 2013, 06:48 AM
Hi Fabio

I suppose that you want to resize images after uploading
Check the following documentation to resize images.
How to Resize Images
Hope this helps

Thanks
Princy.

0
Fabio Cirillo
Top achievements
Rank 1
answered on 20 Feb 2013, 10:15 AM
ok i would use this code:
Private Sub CreateBigThumbNail(ByVal newWidth As Integer, ByVal file As UploadedFile)
Dim target As String = Server.MapPath("~/UploadedImages")
If Not Directory.Exists(target) Then
Directory.CreateDirectory(target)
End If
file.SaveAs(Path.Combine(target, file.GetName()))
Using originalImage As New Bitmap(file.InputStream)
Dim width As Integer = newWidth
Dim height As Integer = (originalImage.Height * newWidth) / originalImage.Width
Dim thumbnail As New Bitmap(width, height)
Using g As Graphics = Graphics.FromImage(DirectCast(thumbnail, System.Drawing.Image))
g.DrawImage(originalImage, 0, 0, width, height)
End Using
Dim thumbnailFileName As String = Path.Combine(target, String.Format("{0}_bthumb{1}", file.GetNameWithoutExtension(), file.GetExtension()))
thumbnail.Save(thumbnailFileName)
End Using
End Sub

and then what value should I enter in the item ByVal file As UploadedFile
Tags
General Discussions
Asked by
Fabio Cirillo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fabio Cirillo
Top achievements
Rank 1
Share this question
or