荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: dongnan (小楠*曾經一個眼神 一分懻動), 信区: Homepage
标  题: 利用ASP获得图象的实际尺寸的示例
发信站: BBS 荔园晨风站 (Tue Oct  3 10:21:12 2000), 转信

利用ASP获得图象的实际尺寸的示例


东楠空间 2000-10-3
< !--#include virtual='/learn/test/lib_graphicdetect.asp'-- >
< html >< head >
< TITLE >dbtable.asp< /TITLE >
< /head >
< body bgcolor='#FFFFFF' >
< %
graphic='images/learnaspiconmain.gif'
HW = ReadImg(graphic)
Response.Write graphic & ' Dimensions: ' & HW(0) & 'x' & HW(1) & '< br
>'
response.write '< img src=''/' & graphic & ''''
response.write height=''' & HW(0) & '''
response.write width=''' & HW(0) & '' >'
% >
< /body >< /html >



The library that is included is:

< %
Dim HW

Function AscAt(s, n)
  AscAt = Asc(Mid(s, n, 1))
End Function

Function HexAt(s, n)
  HexAt = Hex(AscAt(s, n))
End Function


Function isJPG(fichero)
  If inStr(uCase(fichero), '.JPG') < > 0 Then
  isJPG = true
  Else
  isJPG = false
  End If
End Function


Function isPNG(fichero)
  If inStr(uCase(fichero), '.PNG') < > 0 Then
  isPNG = true
  Else
  isPNG = false
  End If
End Function


Function isGIF(fichero)
  If inStr(uCase(fichero), '.GIF') < > 0 Then
  isGIF = true
  Else
  isGIF = false
  End If
End Function


Function isBMP(fichero)
  If inStr(uCase(fichero), '.BMP') < > 0 Then
  isBMP = true
  Else
  isBMP = false
   End If
End Function


Function isWMF(fichero)
  If inStr(uCase(fichero), '.WMF') < > 0 Then
  isWMF = true
  Else
  isWMF = false
  End If
End Function


Function isWebImg(f)
  If isGIF(f) Or isJPG(f) Or isPNG(f) Or isBMP(f) Or isWMF(f) Then
  isWebImg = true
  Else
  isWebImg = true
  End If
End Function


Function ReadImg(fichero)
  If isGIF(fichero) Then
  ReadImg = ReadGIF(fichero)
  Else
  If isJPG(fichero) Then
  ReadImg = ReadJPG(fichero)
  Else
  If isPNG(fichero) Then
  ReadImg = ReadPNG(fichero)
  Els? ReadImg = ReadWMF(fichero)
  Else
  ReadImg = Array(0,0)
  End If
  End If
  End If
  End If
  End If
End Function


Function ReadJPG(fichero)
  Dim fso, ts, s, HW, nbytes
   HW = Array('','')
   Set fso = CreateObject('Scripting.FileSystemObject')
   Set ts = fso.OpenTextFile(Server.MapPath('/' & fichero), 1)
   s = Right(ts.Read(167), 4)
   HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
   HW(1) = HexToDec(HexAt(s,1) & HexAt(s,2))
   ts.Close
  ReadJPG = HW
End Function


Function ReadPNG(fichero)
  Dim fso, ts, s, HW, nbytes
   HW = Array('','')
   Set fso = CreateObject('Scripting.FileSystemObject')
   Set ts = fso.OpenTextFile(Server.MapPath('/' & fichero), 1)
   s = Right(ts.Read(24), 8)  decimal
End Function
% >


--
但得神网无穷力 何惧摘星九重天
  * http://oiu.cn99.com

※ 来源:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 202.204.7.234]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店