å¦Âä½Âè·ç¥页é¢ä¸ÂçÂÂå¾象çÂÂå®Âé 尺寸ï¼Â
<!–#include virtual=”/intels/chunfeng/graphicdetect.asp”–>
<html>xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /??
<head>
<title>Ã¥ÂÂè±é£ÂèÂÂä¹Âè·çÂ¥å¾åÂÂ尺寸</title>
</head>
<body>
<%
ÃÂ graphic=”images/intels.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>
graphicdetect.asp
<%
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)
ÃÂ ÃÂ ÃÂ Else
ÃÂ ÃÂ ÃÂ If isBMP(fichero) Then
ÃÂ ÃÂ ÃÂ ReadImg = ReadPNG(fichero)
ÃÂ ÃÂ ÃÂ Else
ÃÂ ÃÂ ÃÂ If isWMF(fichero) Then
ÃÂ ÃÂ ÃÂ 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)
ÃÂ ÃÂ ÃÂ HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
ÃÂ ÃÂ ÃÂ HW(1) = HexToDec(HexAt(s,7) & HexAt(s,8))
ÃÂ ÃÂ ÃÂ ts.Close
ÃÂ ÃÂ ReadPNG = HW
End Function
Function ReadGIF(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(10), 4)
ÃÂ ÃÂ ÃÂ HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
ÃÂ ÃÂ ÃÂ HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
ÃÂ ÃÂ ÃÂ ts.Close
ÃÂ ÃÂ ReadGIF = HW
End Function
Function ReadWMF(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(14), 4)
ÃÂ ÃÂ ÃÂ HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
ÃÂ ÃÂ ÃÂ HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
ÃÂ ÃÂ ÃÂ ts.Close
ÃÂ ÃÂ ReadWMF = HW
End Function
Function ReadBMP(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)
ÃÂ ÃÂ ÃÂ HW(0) = HexToDec(HexAt(s,4) & HexAt(s,3))
ÃÂ ÃÂ ÃÂ HW(1) = HexToDec(HexAt(s,8) & HexAt(s,7))
ÃÂ ÃÂ ÃÂ ts.Close
ÃÂ ÃÂ ReadBMP = HW
End Function
Function isDigit(c)
ÃÂ ÃÂ ÃÂ If inStr(“0123456789”, c) <> 0 Then
ÃÂ ÃÂ ÃÂ isDigit = true
ÃÂ ÃÂ ÃÂ Else
ÃÂ ÃÂ ÃÂ isDigit = false
ÃÂ ÃÂ ÃÂ End If
End Function
Function isHex(c)
ÃÂ ÃÂ ÃÂ If inStr(“0123456789ABCDEFabcdef”, c) <> 0 Then
ÃÂ ÃÂ ÃÂ isHex = true
ÃÂ ÃÂ ÃÂ Else
ÃÂ ÃÂ ÃÂ ishex = false
ÃÂ ÃÂ ÃÂ End If
End Function
Function HexToDec(cadhex)
ÃÂ ÃÂ ÃÂ Dim n, i, ch, decimal
ÃÂ ÃÂ ÃÂ decimal = 0
ÃÂ ÃÂ ÃÂ n = Len(cadhex)
ÃÂ ÃÂ ÃÂ For i=1 To n
ÃÂ ÃÂ ÃÂ ch = Mid(cadhex, i, 1)
ÃÂ ÃÂ ÃÂ If isHex(ch) Then
ÃÂ ÃÂ ÃÂ decimal = decimal * 16
ÃÂ ÃÂ ÃÂ If isDigit(c) Then
ÃÂ ÃÂ ÃÂ decimal = decimal + ch
ÃÂ ÃÂ ÃÂ Else
ÃÂ ÃÂ ÃÂ decimal = decimal + Asc(uCase(ch)) – Asc(“A”)
ÃÂ ÃÂ ÃÂ End If
ÃÂ ÃÂ ÃÂ Else
ÃÂ ÃÂ ÃÂ HexToDec = -1
ÃÂ ÃÂ ÃÂ End If
ÃÂ ÃÂ ÃÂ Next
ÃÂ ÃÂ ÃÂ HexToDec = decimal
End Function
%>
ÃÂ
[1]