上一篇:一个实用的FSO-实时统计在线人数 >>
如何获知页面上的图象的实际尺寸?
<!--#include virtual="/intels/chunfeng/graphicdetect.asp"-->
<html>
<head>
<TITLE>图像尺寸</TITLE>
</head>
<body bgcolor="#FFFFFF">
<%
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
%>
下一篇:使用FSO把文本信息导入数据库 >>
相关文章:
- · 一个实用的FSO-实时统计在线人数
- · 利用FSO取得BMP,JPG,PNG,GIF文件信息
- · 三种禁用FileSystemObject组件的方法
- · 遍历目录以及目录下文件的函数
- · 在线修改Serv-U 4.2用户密码
- · asp 中常用的文件处理函数
- · 使用FSO把文本信息导入数据库
- · FSO+递归生成文件列表(xml)
- · 文件遍历排序函数
- · 利用FSO取得BMP,JPG,PNG,GIF文件信息
- · fso的一些特殊功能
- · 三种禁用FileSystemObject组件的方法
- · fso的一些特殊功能
- · 利用FSO取得BMP,JPG,PNG,GIF文件信息
- · 三种禁用FileSystemObject组件的方法
- · 清空iis log 中自己登录ip的vbs
- · fso的一些特殊功能
- · 使用FSO按文件大小浏览文件目录并进行删除操作
- · NAV导致IIS调用FSO失败的解决方法
- · 构建免受 FSO 威胁虚拟主机(三)
- · 构建免受 FSO 威胁虚拟主机(二)
- · 构建免受 FSO 威胁虚拟主机(一)
- · 类似于iis浏览的功能
- · 巧用FileSystem组件实现WEB应用中的本地特定打印
- · ASP中FSO对象对IIS WEB服务器数据安全的威胁及对策
- · 文件的读出 编辑 管理
- · 怎样判断一个盘上是否有文件
- · 用ASP实现对MP3曲目信息的操作
- · 关于用ADO STREAM做的无组件上传程序简单介绍
- · 从文本文件中读取信息并存储入数据库
- · 文本搜索
- · FileSystemObject处理文件
- · 设计 FileSystemObject
- · 处理驱动器和文件夹
- · 通过数组给您的文件排序
- · 用ASP做一个TOP COOL的站内搜索
- · 怎样读取一个文本文件的内容?
- · 在线用表单建立文件夹
