Hi all!
I have created an image upload feature on my application that worked well; by taking the image, converting it to a stream then saving the data as a byte in my db.
I now want to resize the image before upload, resizing any image over 500px wide. I have created the function, but whenever I convert the stream (now a MemoryStream rather than my original stream.IO) all of the bytes are 0.
My code is as follows:
ImageStream = file.InputStream
objImage = System.Drawing.Image.FromStream(ImageStream, True)
imgWidth = objImage.Width
imgHeight = objImage.Height
If imgWidth > 500 Then
ResizedHeight = objImage.Height / (objImage.Width / 500)
objThumbnail = objImage.GetThumbnailImage(500, ResizedHeight, Nothing, System.IntPtr.Zero)
End If
Dim ThumbStream As New MemoryStream
objThumbnail.Save(ThumbStream, Imaging.ImageFormat.Jpeg)
Dim uploadedFile(ThumbStream.Length) As Byte
ThumbStream.Read(uploadedFile, 0, ThumbStream.Length)
Any clues where I've gone wrong?
Cheers