Public Function ResizeAndSave(ByVal ImagePath As String, ByVal SavePath As String, ByVal FileName As String,
ByVal xWidth As Int32, ByVal yHeight As Int32) As Boolean
Dim bm As Bitmap
Dim x As Int32 = xWidth
Dim y As Int32 = yHeight
Dim width As Integer = Val(x)
Dim height As Integer = Val(y)
Dim thumb As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(thumb)
Try
Using images As New Bitmap(ImagePath)
Using ms As New MemoryStream()
images.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
bm = Image.FromStream(ms)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(bm, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
g.Dispose()
thumb.Save(Server.MapPath(SavePath) + FileName)
bm.Dispose()
thumb.Dispose()
End Using
End Using
Catch ex As Exception
Throw New Execption(ex.Message)
End Try
Return True
End Function
It is working when I debugging in local.
But when I put it in the server, I get this error message"System.Exception: Parameter is not valid."
How to fix this issue?
If that doesn't fix things, show which line raises the error and the actual values of the variable involved (not what you think they should be, but what they actually are).
Member
2 Points
7 Posts
image.save problem
Aug 04, 2015 12:23 AM|Allen Lim|LINK
It is working when I debugging in local.
But when I put it in the server, I get this error message"System.Exception: Parameter is not valid."
How to fix this issue?
All-Star
194007 Points
28027 Posts
Moderator
Re: image.save problem
Aug 04, 2015 02:10 AM|Mikesdotnetting|LINK
Try
If that doesn't fix things, show which line raises the error and the actual values of the variable involved (not what you think they should be, but what they actually are).
Member
2 Points
7 Posts
Re: image.save problem
Aug 17, 2015 10:04 PM|Allen Lim|LINK
It's working.
Thanks..