asp如何获知页面上的图象的实际尺寸?
来源:asp之家 发布时间:2009-11-24 20:50:00
asp如何获知页面上的图象的实际尺寸大小?
见下面的两个asp文件:
<!--#include virtual="/intels/chunfeng/graphicdetect.asp"-->
<html>
<head>
<TITLE>asp之家asp教程之获知图像尺寸</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
%>
猜你喜欢
- 安装完 anaconda运行如下代码执行不了import numpy as npimport os,sys#获取当前文件夹,并根据文件名de
- 我们可以用Python来将一个网页保存为本地的HTML文件,这需要用到urllib库。比如我们要下载山东大学新闻网的一个页面,该网页如下:实
- 前言利用Python+graphics模块实现AI五子棋。让我们愉快地开始吧~~~效果展示源码import sysimport cfgfro
- 1. IO多路复用O多路复用技术是使用一个可以同时监视多个IO阻塞的中间人去监视这些不同的IO对象,这些被监视的任何一个或多个IO对象有消息
- 1. 关于上传图片失败的问题首先导入jar包 commons-fileupload-1.2.2.jar,ueditor.jar然后修改edi
- 引言周六来公司写点东西,刚好有个icon颜色不对,ui又不在公司,那么就只能自己动手丰衣足食了。呜呜呜,好想住公司,都不用上下班了。svg填
- 写在前面:在做表格的时候,难免会碰到做统计的时候。由于在项目中涉及到做统计的功能比较简单,之后也就没有过多的去研究更复杂的,这里简单记录下。
- 一、简单介绍正则表达式是一种小型的、高度专业化的编程语言,并不是python * 有的,是许多编程语言中基础而又重要的一部分。在python中
- 本文实例讲述了php输出指定时间以前时间格式的方法。分享给大家供大家参考。具体分析如下:比如说你需要在php中输出3天前,20分钟以前,可以
- 每天不同时间段通过微信发消息提醒女友简介有时候,你很想关心她,但是你太忙了,以至于她一直抱怨,觉得你不够关心她。你暗自下决心,下次一定要准时
- 一、identity的基本用法1.含义identity表示该字段的值会自动更新,不需要我们维护,通常情况下我们不可以直接给identity修
- 一 基本知识millisecond 毫秒microsecond 微秒 nanosecond 纳秒1秒=1000毫秒 1毫秒=1000微秒 1
- PyQt中MainWindow, QWidget以及Dialog的区别和选择1. Qt界面分类在Qt Designer设计界面时,首先需要选
- * 对子查询和Join进行了优化,包括对MyISAD和InnoB存储引擎分散范围内的批量索引访问。* 增加了 BACKUP DATABASE
- 本文主要探索的是python的Crypto模块实现AES加密,分享了具体实现代码,下面看看具体内容。学了使用Crypto模块的AES来加密文
- UDPUDP是面向无连接的通讯协议,UDP数据包括目的端口号和源端口号信息,由于通讯不需要连接,所以可以实现广播发送。 UDP传输数据时有大
- phpinfo() 功能描述:输出 PHP 环境信息以及相关的模块、WEB 环境等信息。 危险等级:中 passthru() 功能描述:允许
- 一、硬件要求首先,TensorFlow-gpu不同于CPU版本的地方在于,GPU版本必须有GPU硬件的支撑。TensorFlow对NVIDI
- 有这样一个文本文件,内容有多行如下,数量不定。Lif(__amscript_cd("www.jb51.net")){__
- 本文讲述一个用Python写的小程序,用于有注入点的链接,以检测当前数据库用户是否为sa,详细代码如下:# Code by zhaoxiao