当前位置:编程学习 > asp >>

asp利用JPEG来自动缩小图片

答案:

'利用JPEG来自动缩小图片的。
'fileName为图片的路径
'w为图片的最大宽
'h为图片的最大高度
'
<img src="q.jpg" <%=SetRangw("q.jpg",250,250)%>>
function SetRangw(fileName,w,h)
'fileName="admin/bookpic/2008651444726127.gif"
'w=200
'h=150
  Set fso = CreateObject("Scripting.FileSystemObject")
  if fso.FileExists(server.MapPath(fileName)) then
  Set Jpeg = Server.CreateObject("Persits.Jpeg")
  Jpeg.RegKey = "48958-77556-02411"
  Jpeg.Open server.MapPath(fileName)
  Width=Jpeg.OriginalWidth
  height=Jpeg.OriginalHeight
  Jpeg.close
  Set Jpeg = Nothing
  end if
  Set fso = nothing
  if ((Width>w) or (height>h )) then

  if (Width/height)>(w/h) then
  SetRangw = "Width="&w
  else 
  SetRangw = "height="&h
  end if
  end if
end function

上一个:取得控件的绝对位置
下一个:asp验证第一个字符是否为字母

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,