⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 利用fso取得bmp,jpg,png,gif文件信息.htm

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
📖 第 1 页 / 共 2 页
字号:
            《利用FSO取得BMP,JPG,PNG,GIF文件信息》</FONT></TD></TR>
        <TR>
          <TD bgColor=#586011 colSpan=2 height=1><SPACER type="block" 
            width="1"></TD></TR>
        <TR>
          <TD colSpan=2 height=7></TD></TR>
        <TR>
          <TD align=middle class=p4 
            colSpan=2><B>利用FSO取得BMP,JPG,PNG,GIF文件信息</B></FONT><BR>2002-6-13&nbsp;&nbsp;动网先锋 
          </TD></TR>
        <TR>
          <TD class=p4 colSpan=2>
            <BLOCKQUOTE><BR>&lt;%<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>'::: 
              BMP, GIF, JPG and PNG 
              :::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>'::: 
              :::<BR>'::: This function gets a specified number of bytes from 
              any :::<BR>'::: file, starting at the offset (base 1) :::<BR>'::: 
              :::<BR>'::: Passed: :::<BR>'::: flnm =&gt; Filespec of file to 
              read :::<BR>'::: offset =&gt; Offset at which to start reading 
              :::<BR>'::: bytes =&gt; How many bytes to read :::<BR>'::: 
              :::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>function 
              GetBytes(flnm, offset, bytes)<BR>Dim objFSO<BR>Dim objFTemp<BR>Dim 
              objTextStream<BR>Dim lngSize<BR>on error resume next<BR>Set objFSO 
              = CreateObject("Scripting.FileSystemObject")<BR><BR>' First, we 
              get the filesize<BR>Set objFTemp = objFSO.GetFile(flnm)<BR>lngSize 
              = objFTemp.Size<BR>set objFTemp = nothing<BR>fsoForReading = 
              1<BR>Set objTextStream = objFSO.OpenTextFile(flnm, 
              fsoForReading)<BR>if offset &gt; 0 then<BR>strBuff = 
              objTextStream.Read(offset - 1)<BR>end if<BR>if bytes = -1 then ' 
              Get All!<BR>GetBytes = objTextStream.Read(lngSize) 
              'ReadAll<BR>else<BR>GetBytes = objTextStream.Read(bytes)<BR>end 
              if<BR>objTextStream.Close<BR>set objTextStream = nothing<BR>set 
              objFSO = nothing<BR>end function
              <P></P>
              <P>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>'::: 
              :::<BR>'::: Functions to convert two bytes to a numeric value 
              (long) :::<BR>'::: (both little-endian and big-endian) :::<BR>'::: 
              :::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>function 
              lngConvert(strTemp)<BR>lngConvert = clng(asc(left(strTemp, 1)) + 
              ((asc(right(strTemp, 1)) * 256)))<BR>end function<BR>function 
              lngConvert2(strTemp)<BR>lngConvert2 = clng(asc(right(strTemp, 1)) 
              + ((asc(left(strTemp, 1)) * 256)))<BR>end 
              function<BR><BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>'::: 
              :::<BR>'::: This function does most of the real work. It will 
              attempt :::<BR>'::: to read any file, regardless of the extension, 
              and will :::<BR>'::: identify if it is a graphical image. 
              :::<BR>'::: :::<BR>'::: Passed: :::<BR>'::: flnm =&gt; Filespec of 
              file to read :::<BR>'::: width =&gt; width of image :::<BR>'::: 
              height =&gt; height of image :::<BR>'::: depth =&gt; color depth 
              (in number of colors) :::<BR>'::: strImageType=&gt; type of image 
              (e.g. GIF, BMP, etc.) :::<BR>'::: 
              :::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>function 
              gfxSpex(flnm, width, height, depth, strImageType)<BR>dim strPNG 
              <BR>dim strGIF<BR>dim strBMP<BR>dim strType<BR>strType = 
              ""<BR>strImageType = "(unknown)"<BR>gfxSpex = False<BR>strPNG = 
              chr(137) &amp; chr(80) &amp; chr(78)<BR>strGIF = "GIF"<BR>strBMP = 
              chr(66) &amp; chr(77)<BR>strType = GetBytes(flnm, 0, 3)<BR>if 
              strType = strGIF then ' is GIF<BR>strImageType = "GIF"<BR>Width = 
              lngConvert(GetBytes(flnm, 7, 2))<BR>Height = 
              lngConvert(GetBytes(flnm, 9, 2))<BR>Depth = 2 ^ 
              ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)<BR>gfxSpex = 
              True<BR>elseif left(strType, 2) = strBMP then ' is 
              BMP<BR>strImageType = "BMP"<BR>Width = lngConvert(GetBytes(flnm, 
              19, 2))<BR>Height = lngConvert(GetBytes(flnm, 23, 2))<BR>Depth = 2 
              ^ (asc(GetBytes(flnm, 29, 1)))<BR>gfxSpex = True<BR>elseif strType 
              = strPNG then ' Is PNG<BR>strImageType = "PNG"<BR>Width = 
              lngConvert2(GetBytes(flnm, 19, 2))<BR>Height = 
              lngConvert2(GetBytes(flnm, 23, 2))<BR>Depth = getBytes(flnm, 25, 
              2)<BR>select case asc(right(Depth,1))<BR>case 0<BR>Depth = 2 ^ 
              (asc(left(Depth, 1)))<BR>gfxSpex = True<BR>case 2<BR>Depth = 2 ^ 
              (asc(left(Depth, 1)) * 3)<BR>gfxSpex = True<BR>case 3<BR>Depth = 2 
              ^ (asc(left(Depth, 1))) '8<BR>gfxSpex = True<BR>case 4<BR>Depth = 
              2 ^ (asc(left(Depth, 1)) * 2)<BR>gfxSpex = True<BR>case 6<BR>Depth 
              = 2 ^ (asc(left(Depth, 1)) * 4)<BR>gfxSpex = True<BR>case 
              else<BR>Depth = -1<BR>end select</P>
              <P>else<BR>strBuff = GetBytes(flnm, 0, -1) ' Get all bytes from 
              file<BR>lngSize = len(strBuff)<BR>flgFound = 0<BR>strTarget = 
              chr(255) &amp; chr(216) &amp; chr(255)<BR>flgFound = 
              instr(strBuff, strTarget)<BR>if flgFound = 0 then<BR>exit 
              function<BR>end if<BR>strImageType = "JPG"<BR>lngPos = flgFound + 
              2<BR>ExitLoop = false<BR>do while ExitLoop = False and lngPos &lt; 
              lngSize</P>
              <P>do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos &lt; 
              lngSize<BR>lngPos = lngPos + 1<BR>loop<BR>if asc(mid(strBuff, 
              lngPos, 1)) &lt; 192 or asc(mid(strBuff, lngPos, 1)) &gt; 195 
              then<BR>lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 
              2))<BR>lngPos = lngPos + lngMarkerSize + 1<BR>else<BR>ExitLoop = 
              True<BR>end if<BR>loop<BR>'<BR>if ExitLoop = False then<BR>Width = 
              -1<BR>Height = -1<BR>Depth = -1<BR>else<BR>Height = 
              lngConvert2(mid(strBuff, lngPos + 4, 2))<BR>Width = 
              lngConvert2(mid(strBuff, lngPos + 6, 2))<BR>Depth = 2 ^ 
              (asc(mid(strBuff, lngPos + 8, 1)) * 8)<BR>gfxSpex = True<BR>end 
              if<BR><BR>end if<BR>end function</P>
              <P>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR>'::: 
              Test Harness 
              :::<BR>':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<BR><BR>' 
              To test, we'll just try to show all files with a .GIF extension in 
              the root of C:<BR>Set objFSO = 
              CreateObject("Scripting.FileSystemObject")<BR>Set objF = 
              objFSO.GetFolder("c:\")<BR>Set objFC = 
              objF.Files<BR>response.write "&lt;table border=""0"" 
              cellpadding=""5""&gt;"<BR>For Each f1 in objFC<BR>if 
              instr(ucase(f1.Name), ".GIF") then<BR>response.write 
              "&lt;tr&gt;&lt;td&gt;" &amp; f1.name &amp; "&lt;/td&gt;&lt;td&gt;" 
              &amp; f1.DateCreated &amp; "&lt;/td&gt;&lt;td&gt;" &amp; f1.Size 
              &amp; "&lt;/td&gt;&lt;td&gt;"<BR>if gfxSpex(f1.Path, w, h, c, 
              strType) = true then<BR>response.write w &amp; " x " &amp; h &amp; 
              " " &amp; c &amp; " colors"<BR>else<BR>response.write " "<BR>end 
              if<BR>response.write "&lt;/td&gt;&lt;/tr&gt;"<BR>end 
              if<BR>Next<BR>response.write "&lt;/table&gt;"<BR>set objFC = 
              nothing<BR>set objF = nothing<BR>set objFSO = nothing</P>
              <P>%&gt; <BR><BR></P></BLOCKQUOTE></TD></TR>
        <TR>
          <TD class=p4 vAlign=top width="50%">
            <BLOCKQUOTE>原作者:大洲<BR>来 源:开发者俱乐部<BR>共有5095位读者阅读过此文<BR>【<A 
              href="http://bbs.aspsky.net/list.asp?boardid=1">发表评论</A>】 
            </BLOCKQUOTE></TD>
          <TD class=p4 vAlign=top width="50%">
            <P>
            <LI><FONT color=#0772b1>上篇文章</FONT>:<A 
            href="http://www.aspsky.net/article/list.asp?id=2746">使用NextRecordset通过一个Connection输出多个select查询</A> 
            <BR>
            <LI><FONT color=#0772b1>下篇文章</FONT>:<A 
            href="http://www.aspsky.net/article/list.asp?id=2748">VBS、ASP代码语法加亮显示的类(1)</A> 
            </LI></TD></TR>
        <TR>
          <TD bgColor=#297dff class=p4 height=20 width="50%"><FONT 
            color=#ceffff>&nbsp;→ 本周热门</FONT></TD>
          <TD bgColor=#297dff class=p4 width="50%"><FONT color=#ceffff>&nbsp;→ 
            相关文章</FONT></TD></TR>
        <TR>
          <TD bgColor=#586011 colSpan=2 height=1><SPACER type="block" 
            width="1"></TD></TR>
        <TR>
          <TD colSpan=2 height=7></TD></TR>
        <TR>
          <TD class=p4 vAlign=top width="50%">
            <LI><A href="http://www.aspsky.net/article/list.asp?id=1510" 
            target=_top title="SQL Server 7.0 入门(一)">SQL Server 7.0 
            入门(...</A>[<FONT color=red>7239</FONT>]<BR>
            <LI><A href="http://www.aspsky.net/article/list.asp?id=1540" 
            target=_top title=PHP4实际应用经验篇(1)>PHP4实际应用经验篇(1)</A>[<FONT 
            color=red>7135</FONT>]<BR>
            <LI><A href="http://www.aspsky.net/article/list.asp?id=1536" 
            target=_top 
            title=无组件文件上传代码实例(支持多文件上传及文件和input域混合上传)>无组件文件上传代码实例(支持多文件上...</A>[<FONT 
            color=red>6029</FONT>]<BR>
            <LI><A href="http://www.aspsky.net/article/list.asp?id=2557" 
            target=_top title=树型结构在ASP中的简单解决>树型结构在ASP中的简单解决</A>[<FONT 
            color=red>5757</FONT>]<BR>
            <LI><A href="http://www.aspsky.net/article/list.asp?id=1545" 
            target=_top title=PHP4实际应用经验篇(6)>PHP4实际应用经验篇(6)</A>[<FONT 
            color=red>5599</FONT>]<BR>
            <LI><A href="http://www.aspsky.net/article/list.asp?id=2563" 
            target=_top title=一个老个写的无组件上传>一个老个写的无组件上传</A>[<FONT 
            color=red>5013</FONT>]<BR>
            <LI><A href="http://www.aspsky.net/article/list.asp?id=1542" 
            target=_top title=PHP4实际应用经验篇(3)>PHP4实际应用经验篇(3)</A>[<FONT 
            color=red>4731</FONT>]<BR></LI></TD>
          <TD class=p4 vAlign=top width="50%">
            <LI><A 
            href="http://www.aspsky.net/article/list.asp?id=2747">利用FSO取得BMP,JPG,PNG,GIF文件信息</A><BR>
            <LI><A 
            href="http://www.aspsky.net/article/list.asp?id=1063">PHP中如何在输出内容后再输出头信息?</A><BR></LI></TD></TR>
        <TR>
          <TD colSpan=2 height=7></TD></TR></TBODY></TABLE>
    <TD bgColor=#297dff width=1> </TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
  <TBODY>
  <TR>
    <TD bgColor=#297dff height=1><SPACER type="block" 
width="1"></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
  <TBODY>
  <TR>
    <TD align=middle height=30></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
  <TBODY>
  <TR>
    <TD align=middle class=p2 width="100%">
      <TABLE border=0 cellPadding=0 cellSpacing=0 width=755>
        <TBODY>
        <TR>
          <TD align=middle class=p2 width="100%">
            <P align=center><A 
            href="http://www.aspsky.net/produce/index.asp">客户服务</A> -- <A 
            href="http://www.aspsky.net/aspads.asp">广告合作</A> -- <A 
            href="http://www.aspsky.net/about.asp">关于本站</A> -- <A 
            href="http://www.aspsky.net/tell.asp">联系方法</A><BR><BR>动网先锋版权所有 <FONT 
            face=Verdana, size=1 Arial, Helvetica, sans-serif>Copyright &copy; 
            2000-2001 <B>AspSky<FONT color=#cc0000>.Net</FONT></B>, All Rights 
            Reserved .</FONT> 
</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -