The following two files:
<! -- # Include virtual = "/intels/chunfeng/graphicdetect. asp" -->
<Html>
<Head>
<TITLE> image size </TITLE>
</Head>
<Body bgcolor = "# FFFFFF">
<%
Graphic = "images/intels.gif"
HW = ReadImg (graphic)
Response. Write graphic & "Dimensions:" & HW (0) & "x" & HW (1)
& "<Br>"
Response. write "
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 ("0123456789 ABCDEFabcdef", 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 ("")
End If
Else
HexToDec =-1
End If
Next
HexToDec = decimal
End Function
%>