如何獲知頁(yè)面上的圖象的實(shí)際尺寸?
如何獲知頁(yè)面上的圖象的實(shí)際尺寸?
<!--#include virtual="/intels/chunfeng/graphicdetect.asp"-->
<html><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<head>
<title>千花飛舞之獲知圖像尺寸</title>
</head>
<body>
<%
  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
%>
 
[1]
欄 目:編程問(wèn)答
下一篇:如何防止計(jì)數(shù)器刷新計(jì)數(shù)?
本文標(biāo)題:如何獲知頁(yè)面上的圖象的實(shí)際尺寸?
本文地址:http://www.jygsgssxh.com/a1/bianchengwenda/12090.html
您可能感興趣的文章
- 01-11如何實(shí)現(xiàn)點(diǎn)擊數(shù)的計(jì)算?
 - 01-11如何判斷電子郵件的地址格式是否正確?
 - 01-11如何做一個(gè)文本搜索?
 - 01-11如何實(shí)現(xiàn)網(wǎng)上考試?
 - 01-11如何實(shí)現(xiàn)全文檢索?
 - 01-11如何用POP3接收電子郵件?
 - 01-11如何使用表單發(fā)送電子郵件?
 - 01-11如何在線更改密碼?
 - 01-11如何取回已忘記的密碼?
 - 01-11如何做一個(gè)隨機(jī)密碼產(chǎn)生器?
 


閱讀排行
- 1C語(yǔ)言 while語(yǔ)句的用法詳解
 - 2java 實(shí)現(xiàn)簡(jiǎn)單圣誕樹(shù)的示例代碼(圣誕
 - 3利用C語(yǔ)言實(shí)現(xiàn)“百馬百擔(dān)”問(wèn)題方法
 - 4C語(yǔ)言中計(jì)算正弦的相關(guān)函數(shù)總結(jié)
 - 5c語(yǔ)言計(jì)算三角形面積代碼
 - 6什么是 WSH(腳本宿主)的詳細(xì)解釋
 - 7C++ 中隨機(jī)函數(shù)random函數(shù)的使用方法
 - 8正則表達(dá)式匹配各種特殊字符
 - 9C語(yǔ)言十進(jìn)制轉(zhuǎn)二進(jìn)制代碼實(shí)例
 - 10C語(yǔ)言查找數(shù)組里數(shù)字重復(fù)次數(shù)的方法
 
本欄相關(guān)
- 01-11如何實(shí)現(xiàn)點(diǎn)擊數(shù)的計(jì)算?
 - 01-11如何做一個(gè)文本搜索?
 - 01-11如何判斷電子郵件的地址格式是否正
 - 01-11如何實(shí)現(xiàn)全文檢索?
 - 01-11如何實(shí)現(xiàn)網(wǎng)上考試?
 - 01-11如何使用表單發(fā)送電子郵件?
 - 01-11如何用POP3接收電子郵件?
 - 01-11如何取回已忘記的密碼?
 - 01-11如何在線更改密碼?
 - 01-11如何做一個(gè)隨機(jī)密碼產(chǎn)生器?
 
隨機(jī)閱讀
- 04-02jquery與jsp,用jquery
 - 01-10SublimeText編譯C開(kāi)發(fā)環(huán)境設(shè)置
 - 01-10使用C語(yǔ)言求解撲克牌的順子及n個(gè)骰子
 - 01-10C#中split用法實(shí)例總結(jié)
 - 01-11Mac OSX 打開(kāi)原生自帶讀寫NTFS功能(圖文
 - 08-05織夢(mèng)dedecms什么時(shí)候用欄目交叉功能?
 - 01-10delphi制作wav文件的方法
 - 01-11ajax實(shí)現(xiàn)頁(yè)面的局部加載
 - 08-05dedecms(織夢(mèng))副欄目數(shù)量限制代碼修改
 - 08-05DEDE織夢(mèng)data目錄下的sessions文件夾有什
 


