aspx thread: Saving images to a stream.
Hello Everyone and thanks for your help in advance. I am
working on an application that allows the user to upload
an image to insert in SQL Server. Before insertion, the
image is resized. I am usinge the image.FromStream()
method to upload. However, I am having two problems. I
cannot seem to get the save to work properly for the
stream. Second, I don't understand why I have to convert
it to a stream in the first place to insert in an image
column in SQL Server. The code I am using is:
'Read the image as an image for resizing
orginalimg=orginalimg.FromStream
(PersonImage.PostedFile.InputStream)
'Calculations for Resizing
width = orginalimg.Width
height = orginalimg.Height
' Calculate width
If width>100 Then
width = 100
height = height*(100/orginalimg.width)
End If
thumb = orginalimg.GetThumbnailImage(width,
height, Nothing, inp)
'Save the Thumbnail as a stream
thumb.Save(MyMemory, ImageFormat.Jpeg)
Dim imageData As Byte = MyMemory.Length
MyMemory.Read(imageData, 0, MyMemory.Length)
Any help you could give would be greatly appreciated. Thanks.