网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.如何正确处理数据库中的Null.
.一个查看ASP的JavaScript程序.
.利用XSL和ASP实现XML文档在线编辑.
.ASP中文本文件与数据库文件的数据.
.ASP关于动态数据显示页面得锚点.
.用ASP和WML来实现数据库查询.
.了解MSMQ,控制ASP进程 (一).
.使用ADO批量更新记录(源代码).
.关于Global.asa文件的深入研究与.
.SQL Server中单引号的两种处理技.
.教你一次下载网页中的所有资源.
.从ASP调用SQL中的图像.
.利用XML不离开页面刷新数据.
.使用索引服务器 - 增加属性.
.6行代码实现无组件上传.
.ASP获取客户端MAC地址.
.提供一种“间接防止另存为”的方.
.最大限度优化你的Asp性能.
.一个在vbscript中读取cookie的程.
.改善ASP性能和外观的技巧集锦(下.

利用ASP获得图象的实际尺寸的示例

发表日期:2000-10-20


<!--#include virtual="/learn/test/lib_graphicdetect.asp"-->
<html><head>
<TITLE>dbtable.asp</TITLE>
</head>
<body bgcolor="#FFFFFF">
<%
   graphic="images/learnaspiconmain.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>



The library that is included is:

<%
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
%>

上一篇:VisualInterDev6.0七种实现分页显示的方法 人气:11517
下一篇:介绍一种效率极高的分类算法 人气:11067
浏览全部ASP的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐