1<html><head>
2<title>dbtable.asp</title>
3</head>
4<body bgcolor="#FFFFFF">
graphic="images/learnaspiconmain.gif"
HW = ReadImg(graphic)
Response.Write graphic & " Dimensions: " & HW(0) & "x" & HW(1) & "<br/>"
response.write "<img "="" ""="" """="" """"="" &="" graphic="" height="" hw(0)="" response.write="" src="" width=""/>"
1</body></html>
The library that is included is:
1
2Dim HW
3
4Function AscAt(s, n)
5AscAt = Asc(Mid(s, n, 1))
6End Function
7
8Function HexAt(s, n)
9HexAt = Hex(AscAt(s, n))
10End Function
11
12
13Function isJPG(fichero)
14If inStr(uCase(fichero), ".JPG") <> 0 Then
15isJPG = true
16Else
17isJPG = false
18End If
19End Function
20
21
22Function isPNG(fichero)
23If inStr(uCase(fichero), ".PNG") <> 0 Then
24isPNG = true
25Else
26isPNG = false
27End If
28End Function
29
30
31Function isGIF(fichero)
32If inStr(uCase(fichero), ".GIF") <> 0 Then
33isGIF = true
34Else
35isGIF = false
36End If
37End Function
38
39
40Function isBMP(fichero)
41If inStr(uCase(fichero), ".BMP") <> 0 Then
42isBMP = true
43Else
44isBMP = false
45End If
46End Function
47
48
49Function isWMF(fichero)
50If inStr(uCase(fichero), ".WMF") <> 0 Then
51isWMF = true
52Else
53isWMF = false
54End If
55End Function
56
57
58Function isWebImg(f)
59If isGIF(f) Or isJPG(f) Or isPNG(f) Or isBMP(f) Or isWMF(f) Then
60isWebImg = true
61Else
62isWebImg = true
63End If
64End Function
65
66
67Function ReadImg(fichero)
68If isGIF(fichero) Then
69ReadImg = ReadGIF(fichero)
70Else
71If isJPG(fichero) Then
72ReadImg = ReadJPG(fichero)
73Else
74If isPNG(fichero) Then
75ReadImg = ReadPNG(fichero)
76Else
77If isBMP(fichero) Then
78ReadImg = ReadPNG(fichero)
79Else
80If isWMF(fichero) Then
81ReadImg = ReadWMF(fichero)
82Else
83ReadImg = Array(0,0)
84End If
85End If
86End If
87End If
88End If
89End Function
90
91
92Function ReadJPG(fichero)
93Dim fso, ts, s, HW, nbytes
94HW = Array("","")
95Set fso = CreateObject("Scripting.FileSystemObject")
96Set ts = fso.OpenTextFile(Server.MapPath("/" & fichero), 1)
97s = Right(ts.Read(167), 4)
98HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
99HW(1) = HexToDec(HexAt(s,1) & HexAt(s,2))
100ts.Close
101ReadJPG = HW
102End Function
103
104
105Function ReadPNG(fichero)
106Dim fso, ts, s, HW, nbytes
107HW = Array("","")
108Set fso = CreateObject("Scripting.FileSystemObject")
109Set ts = fso.OpenTextFile(Server.MapPath("/" & fichero), 1)
110s = Right(ts.Read(24), 8)
111HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4))
112HW(1) = HexToDec(HexAt(s,7) & HexAt(s,8))
113ts.Close
114ReadPNG = HW
115End Function
116
117
118Function ReadGIF(fichero)
119Dim fso, ts, s, HW, nbytes
120HW = Array("","")
121Set fso = CreateObject("Scripting.FileSystemObject")
122Set ts = fso.OpenTextFile(Server.MapPath("/" & fichero), 1)
123s = Right(ts.Read(10), 4)
124HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
125HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
126ts.Close
127ReadGIF = HW
128End Function
129
130
131Function ReadWMF(fichero)
132Dim fso, ts, s, HW, nbytes
133HW = Array("","")
134Set fso = CreateObject("Scripting.FileSystemObject")
135Set ts = fso.OpenTextFile(Server.MapPath("/" & fichero), 1)
136s = Right(ts.Read(14), 4)
137HW(0) = HexToDec(HexAt(s,2) & HexAt(s,1))
138HW(1) = HexToDec(HexAt(s,4) & HexAt(s,3))
139ts.Close
140ReadWMF = HW
141End Function
142
143
144Function ReadBMP(fichero)
145Dim fso, ts, s, HW, nbytes
146HW = Array("","")
147Set fso = CreateObject("Scripting.FileSystemObject")
148Set ts = fso.OpenTextFile(Server.MapPath("/" & fichero), 1)
149s = Right(ts.Read(24), 8)
150HW(0) = HexToDec(HexAt(s,4) & HexAt(s,3))
151HW(1) = HexToDec(HexAt(s,8) & HexAt(s,7))
152ts.Close
153ReadBMP = HW
154End Function
155
156
157Function isDigit(c)
158If inStr("0123456789", c) <> 0 Then
159isDigit = true
160Else
161isDigit = false
162End If
163End Function
164
165
166Function isHex(c)
167If inStr("0123456789ABCDEFabcdef", c) <> 0 Then
168isHex = true
169Else
170ishex = false
171End If
172End Function
173
174
175Function HexToDec(cadhex)
176Dim n, i, ch, decimal
177decimal = 0
178n = Len(cadhex)
179For i=1 To n
180ch = Mid(cadhex, i, 1)
181If isHex(ch) Then
182decimal = decimal * 16
183If isDigit(c) Then
184decimal = decimal + ch
185Else
186decimal = decimal + Asc(uCase(ch)) - Asc("A")
187End If
188Else
189HexToDec = -1
190End If
191Next
192HexToDec = decimal
193End Function