I'm using this code (VB) to upload an image to an upload folder on my site:
If Not (FileUpload1.PostedFile Is Nothing) Then 'Check to make sure we actually have a file to upload
labelStatus.Text = ""
Dim strLongFilePath As String = FileUpload1.PostedFile.FileName
Dim intFileNameLength As Integer = InStr(1, StrReverse(strLongFilePath), "\")
Dim strFileName As String = Mid(strLongFilePath, (Len(strLongFilePath) - intFileNameLength) + 2)
Dim a As String = Server.MapPath("")
a = Strings.Replace(a, "workshops", "")
Select Case FileUpload1.PostedFile.ContentType
Case "image/pjpeg", "image/jpeg" 'Make sure we are getting a valid JPG image
FileUpload1.PostedFile.SaveAs(a & "\uploads\images\" & UserID & "_" & strFileName)
labelStatus.Text = strFileName & " was uploaded successfully"
'Not a valid jpeg image
labelStatus.Text = "Not a valid jpg/jpeg image"
This code works great...what I need is how do I integrate a function to resize the image to 200x200 before it is saved? (or save it, then resize it, then resave it- whatever is easier)
Specifically, I need to know how to do the resize while using the code above. I've found various chunks of code about resizing an image (ie. "true image resizing" article from 4 guys rozilla), but have no idea how to integrate such code with the code I have above. I need a solution that can integrate with the code I already have.