Hi, after some searchs, i've discovered this code
Public Sub ResizeImage(ByVal scaleFactor As Double, ByVal fromStream As Stream, ByVal toStream As Stream)
Dim image__1 = System.Drawing.Image.FromStream(fromStream)
Dim newWidth = CInt(image__1.Width * scaleFactor)
Dim newHeight = CInt(image__1.Height * scaleFactor)
Dim thumbnailBitmap = New System.Drawing.Bitmap(newWidth, newHeight)
Dim thumbnailGraph = System.Drawing.Graphics.FromImage(thumbnailBitmap)
thumbnailGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality
thumbnailGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
thumbnailGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic
Dim imageRectangle = New System.Drawing.Rectangle(0, 0, newWidth, newHeight)
thumbnailGraph.DrawImage(image__1, imageRectangle)
thumbnailBitmap.Save(toStream, image__1.RawFormat)
thumbnailGraph.Dispose()
thumbnailBitmap.Dispose()
image__1.Dispose()
End Sub
There are 2 things i can't "modify" to solve my problem:
- I wouldn't like to pass a stream, but i prefer to pass a path (like C:\mysite\photo\myphoto.gif") ... how can i "convert" it to accept a file and not a stream ?
- In this function i've to pass a "scale" value. But I prefer to check if the image is too big (for example > 1024x768) than resize it to a max of 1024x768. How can i check this with system.drawing.
As you can see i don't know anything about System.Drawing so i need an "hard" help to solve this job.
Thank you very much in advance!