62,254
社区成员
发帖
与我相关
我的任务
分享Dim image, anewimage As System.Drawing.Image
Dim width, height, newwidth, newheight As Integer
Dim callb As System.Drawing.Image.GetThumbnailImageAbort
FileUp.PostedFile.SaveAs(Server.MapPath(".") & "/images/" & filename & ".jpg")
'生成缩略图
image = System.Drawing.Image.FromFile(Server.MapPath(".") & "/images/" + filename + ".jpg")
width = image.Width
height = image.Height
'If width > height Then
' newwidth = 250
' newheight = image.Height / image.Width * newwidth
'Else
' newheight = 250
' newwidth = image.Width / image.Height * newheight
'End If
''固定大小
newheight = 200
newwidth = 200
Response.Write("id=" + CStr(ID) + "width=" + CStr(width) + ";height=" + CStr(height) + " ")
Response.Write("newwidth=" + CStr(newwidth) + ";newheight=" + CStr(newheight) + "<br>")
anewimage = image.GetThumbnailImage(newwidth, newheight, callb, New System.IntPtr)
anewimage.Save(Server.MapPath(".") & "/smallpic/" + filename + ".jpg")
image.Dispose()