Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

I am trying to upload an image, and resize it automatically onto a web server. I have successfully uploaded the file, and I am able to rename it and change the file extention on it. Here is the code that I am using:

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)

FileUpload1.PostedFile.SaveAs(Server.MapPath("\Samples\") & strFileName)

 

What I am having a problem with is in resizing the file. I have been looking on google but the examples I have found are related to window applications.

 

Any suggestions?

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Hi all

 

Here is the code that I am using to resize the image, it fires off without an exception, however, it does not seem to create the new image.

Private Sub ResizeImage(ByRef fileName As String, ByVal factor As Integer)
Dim img As Bitmap
Dim imageResize As Bitmap
Dim fs As New FileStream(Server.MapPath("\Samples\") & fileName, FileMode.Open, FileAccess.Read)
Dim imgData(fs.Length) As Byte
Dim ms As New MemoryStream()

fs.Read(imgData, 0, fs.Length)
fs.Close()

Try
 img = Image.FromStream(New MemoryStream(imgData))
 imageResize = New Bitmap(img, New Size(img.Size.Width * factor, img.Size.Height * factor))
 imageResize.Save(ms, Imaging.ImageFormat.Bmp)
Catch ex As Exception
 Stop
End Try 
End Sub

 

Any suggestions?

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

So how should I be saving it, I was using img, but that didn't seem logical.

 

Mike55.

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...