<% Sub PlaceImage(filename, maxdim) Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(Server.MapPath(filename)) Then filename = "graphics/no_foto.jpg" End If HW = ReadJPG(filename) If HW(0) = "" Then HW(0) = maxdim If HW(1) = "" Then HW(1) = maxdim If HW(0) > maxdim Or HW(1) > maxdim Then If HW(0) > HW(1) Then w = maxdim h = Int(maxdim * (HW(1) / HW(0))) Else h = maxdim w = Int(maxdim * (HW(0) / HW(1))) End If Else w = HW(0) h = HW(1) End If %> <% End Sub Function ReadJPG(fichero) Const maxJpegSearch = 2048 Dim fso, ts, s, HW, nbytes, x, SOF HW = Array("","") Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.OpenTextFile(Server.MapPath(fichero), 1) s = ts.Read(maxJpegSearch) ts.Close for x = 1 to Len(s) - 1 if Asc(Mid(s, x, 1)) = &hFF then if Asc(Mid(s, x + 1, 1)) >= &hC0 AND _ Asc(Mid(s, x + 1, 1)) <= &hCF AND _ Asc(Mid(s, x + 1, 1)) <> &hC4 then SOF = x exit for end if end if next if SOF > 0 then s = Mid(s, SOF + 5, 4) HW(0) = HexToDec(HexAt(s,3) & HexAt(s,4)) HW(1) = HexToDec(HexAt(s,1) & HexAt(s,2)) else HW(0) = -1 HW(1) = -1 end if ReadJPG = HW End Function Function HexAt(s, n) HexAt = Hex(AscAt(s, n)) End Function Function AscAt(s, n) AscAt = Asc(Mid(s, n, 1)) 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(ch) Then decimal = decimal + ch Else decimal = decimal + 10 + Asc(uCase(ch)) - Asc("A") End If Else HexToDec = -1 End If Next HexToDec = decimal End Function %>