επίσης με τον παρακάτω τρόπο:
'==================Copy following Function for resizing image====================
Function ResizeImage(ByVal streamImage As Stream, ByVal maxWidth As Int32, ByVal maxHeight As Int32) As Bitmap
Dim originalImage As New Bitmap(streamImage)
Dim newWidth As Int32 = originalImage.Width
Dim newHeight As Int32 = originalImage.Height
Dim aspectRatio As Double = Double.Parse(originalImage.Width) / Double.Parse(originalImage.Height)
If (aspectRatio <= 1 And originalImage.Width > maxWidth) Then
newWidth = maxWidth
newHeight = CInt(Math.Round(newWidth / aspectRatio))
Else
If (aspectRatio > 1 And originalImage.Height > maxHeight) Then
newHeight = maxHeight
newWidth = CInt(Math.Round(newHeight * aspectRatio))
End If
End If
Dim newImage As New Bitmap(originalImage, newWidth, newHeight)
Dim g As Graphics = Graphics.FromImage(newImage)
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear
g.DrawImage(originalImage, 0, 0, newImage.Width, newImage.Height)
originalImage.Dispose()
Return newImage
End Function
'======================================
και μετά :
Dim extension As String = Path.GetExtension(FileUpload1.PostedFile.FileName)
Dim filepreview As Image = (ResizeImage(FileUpload1.PostedFile.InputStream, 640, 480))
filepreview.Save((uploadFolder & returnvalue & "-1") + extension)
filepreview.Dispose()
μου σώζει τις εικόνες σαν PNG
Εγώ θα ήθελα σαν JPG και με δυνατότητα να παίζω με την συμπίεση (ποιόητα) της εικόνας.
Καμιά βοήθεια;