Dim originalpath As String = (Server.MapPath("~/uploads/"))
Dim strThumbPath As String = Server.MapPath("/thumbs/")
Dim originalname As String = FileUpload1.FileName
'load original image
Dim myimg As System.Drawing.Image
myimg = System.Drawing.Image.FromFile(originalpath & originalname)
Dim newwidth As Integer = 100
Dim newheight As Integer = 100
'size the thumbnail
myimg.GetThumbnailImage(newwidth, newheight, Nothing, New IntPtr())
'save the thumbnail
myimg.Save(Server.MapPath("~/thumbs/thumb_") & originalname)
The file is saved in the correct folder with the correct name, but it has not been resized. Any thoughts as to why?
GetThumbnailImage returns a new image that you need to save. You were just resaving the original.
Try it like this:
Dim thumb As System.Drawing.Image = myimg.GetThumbnailImage(newwidth, newheight, Nothing, New IntPtr())
thumb.Save(Server.MapPath("~/thumbs/thumb_") & originalname)
Member
23 Points
102 Posts
GetThumbnailImage is not resizing the image when saved
Dec 27, 2010 01:48 PM|chekmate111|LINK
The file is saved in the correct folder with the correct name, but it has not been resized. Any thoughts as to why?
All-Star
159984 Points
13198 Posts
ASPInsiders
Moderator
Re: GetThumbnailImage is not resizing the image when saved
Dec 27, 2010 01:58 PM|mbanavige|LINK
GetThumbnailImage returns a new image that you need to save. You were just resaving the original.
Try it like this:
Dim thumb As System.Drawing.Image = myimg.GetThumbnailImage(newwidth, newheight, Nothing, New IntPtr())
thumb.Save(Server.MapPath("~/thumbs/thumb_") & originalname)
Member
23 Points
102 Posts
Re: GetThumbnailImage is not resizing the image when saved
Dec 27, 2010 02:44 PM|chekmate111|LINK
Thank you for the help!!
As a side note, I like your avatar of the avatar. :)