如何获知页面上的图象的实际尺寸

页面

下面两个文件:
<!--#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
%>

时间: 2024-09-09 09:54:15

如何获知页面上的图象的实际尺寸的相关文章

如何获知页面上的图象的实际尺寸?

页面 下面两个文件:<!--#include virtual="/intels/chunfeng/graphicdetect.asp"--><html><head><TITLE>图像尺寸</TITLE></head><body bgcolor="#FFFFFF"><% graphic="images/intels.gif" HW = ReadImg(grap

如何获知页面上的图象的实际尺寸?_FSO专题

下面两个文件: <!--#include virtual="/intels/chunfeng/graphicdetect.asp"--> <html> <head> <TITLE>图像尺寸</TITLE> </head> <body bgcolor="#FFFFFF"> <% graphic="images/intels.gif" HW = ReadImg(

图片-通过jsp页面上传图,路径保存到oracle中,怎么能在上传的时候把文件的名字改成自己想要的

问题描述 通过jsp页面上传图,路径保存到oracle中,怎么能在上传的时候把文件的名字改成自己想要的 图片保存到磁盘后,当我想换掉这个图片时,用什么方法可以用新的图片覆盖掉老图片 解决方案 一般存路径就是文件改过名字的路径,再次保存新图片,取得原来的路径删除呗,然后在存 解决方案二: 上传的时候重命名同时将文件路径的信息保存到数据库. 硬盘保存文件 . 解决方案三: 用文件流写文件的时候路径不就是名字 解决方案四: 上传的时候用自己想要的名字存在服务器上就行了

如何将jfreechart做好的图在页面上显示啊?

问题描述 用jfreechart做的一个.java文件,在MyEclipse中已经调试通过了(RunAs-->JavaApplication),在弹出的窗口图已经显示出来了.但是我不知道如何把它转到web页面上,请教各位高手:packageTest;importjava.awt.*;importjava.text.NumberFormat;importjavax.servlet.http.HttpSession;importjavax.servlet.jsp.JspWriter;importja

WAP页面在手机QQ浏览器上背景图不显示

问题描述 各位WAP高手帮帮忙,我做的wap页面在手机QQ浏览器上背景图不显示,在其他手机浏览器显示正常,这是什么问题导致的??? 解决方案 解决方案二:引用楼主gaofei019的回复: 各位WAP高手帮帮忙,我做的wap页面在手机QQ浏览器上背景图不显示,在其他手机浏览器显示正常,这是什么问题导致的??? 应该是兼容问题~·楼主好好查查代码吧解决方案三:楼主,你说的qq浏览器是在什么手机上?如果是塞班s60的话,确实是不支持的.塞班手机上的浏览器,如:ucweb和qq,以及其他的浏览器,基本

一段实现页面上的图片延时加载的js代码_图象特效

相关地址:http://list.taobao.com/browse/30-50029375/n-1----------------------0---------yes-------g,ge3denzxhazdumzsgy3tsnzq-----------------------42-grid-commend-0-all-50029375.htm?TBG=14153.14.7&ssid=r18-s18 http://shop.qq.com/shopList.html 大家如果使用firebug

在自己的网页页面上实现Google PR值的显示

google|pr值|网页|显示|页面 Google本身提供了查询指定的url的PageRank值的接口,知道了这个接口,就可以很容易编写脚本在页面上实现这一功能,而无需再依赖google toolbar才能进行查询.本文提供了一个用PHP实现的pr查询接口. 使用很简单,只要在需要的地方 〈?php include_once("./pr.inc.php"); echo getPR($urlToQuery); ?〉 即可显示出指定url的PageRank的数值.知道了这个数值再在其基础

如何获取设置图片大小以适应大小在页面上显示

显示|页面 大家知道,丰富多彩的Web页面离不开图片的支持,图像一方面增加了网页的生动性,另一方面增加了网页规模,使下载速度减慢.如何让一图片能以适当大小在页面上显示,成了我一时解不开的谜. 前不久,我为单位开发了一个教学科研网站,采用新闻管理系统,首页上新闻栏目中,需要从数据库中调用图片文件作为图片新闻中的图片,从而形成文字绕排形式.由于整个系统包括新闻上传.新闻编辑.系统公告等都是动态实现的.在开发的过程中,我考虑到以下几个因素:(1)作为网站的维护者,对计算机的操作不太熟练:(2)网站讲究

xp系统浏览器页面上的链接打不开是怎么回事

  xp系统浏览器页面上的链接打不开是怎么回事?近来,很多中关村xp系统用户在使用浏览器浏览点击网页时,都遇到了一些故障问题.他们反馈能打开网页但是网页上的链接怎么也打不开,显示的是空白网页,这该怎么办呢?下面,就随小编看看该问题的具体解决方法吧! 具体如下: 经过查看,电脑DNS已经做了正确设置. 首先使用常用的解决IE无法打开二次链接的处理方法: 在"开始-运行"输入以下几个命令:Regsvr32 urlmon.dll.Regsvr32 actxprxy.dll.Regsvr32