adodb.stream 取 .png 图片完整文件头信息

摘要:
主要目的为取 .png文件 的高宽度信息, 使用ASP完成(不用外建组件).
进一步了解请查看相关文章.

作用:
本文使用 ASP 的内置组件 adodb.stream 取得 .png 的头部信息, 包括高宽度信息.

相关文章:
1. ASP adodb.stream 取 Win32 .bmp 图片完整文件头信息 By shawl.qiu
URL:   
http://blog.csdn.net/btbtd/archive/2006/09/16/1228908.aspx

2. ASP adodb.stream 取 .gif 图片完整文件头&描述信息 By shawl.qiu
URL:   
http://blog.csdn.net/btbtd/archive/2006/09/17/1232530.aspx

目录:
1. 主内容: 完整例子
2. 参考文献
3. 预览

附: 测试图片 

shawl.qiu
2006-09-17
 
http://blog.csdn.net/btbtd/

1. 主内容: 完整例子
    linenum
    • <%
    •     dim file:file=server.MapPath("a.png")
    •     dim temp
    •     dim stm
    •     set stm=createObject("adodb.stream")
    •         with stm
    •             .type = 1
    •             .open
    •             .loadFromFile file
    •             temp=.read
    •             .close
    •         end with    
    •     set stm=nothing
    •         response.write "png file info:<br/>"
    •         response.write "<br/>#2-4/3 Header Signature: "&binToStr(midB(temp,2,3))
    •         response.write "<br/>#12-16/4 First chunk(IHDR): "&binToStr(midB(temp,12,5))
    •         response.write "<br/>#17-20/4 Width: "&binToNumPng(midB(temp,17,4))
    •         response.write "<br/>#21-24/4 Height: "&binToNumPng(midB(temp,21,4))
    •         response.write "<br/>#25-25/1 Bit depth: "&binToNumPng(midB(temp,25,1))
    •         response.write "<br/>#26-26/1 ColorType: "&binToNumPng(midB(temp,26,1))
    •         response.write "<br/>#27-27/1 Compression method: "&binToNumPng(midB(temp,17,1))
    •         response.write "<br/>#28-28/1 Filter method: "&binToNumPng(midB(temp,28,1))
    •         response.write "<br/>#29-29/1 Interlace method: "&binToNumPng(midB(temp,29,1))
    •  
    •     private function binToNumPng(bin)
    •     '二进制转为 Numeric (png)
    •         dim i:binToNumPng=0
    •         for i=1 to lenB(bin)
    •             binToNumPng=binToNumPng*256+ascB(midB(bin,i,1))
    •         next 'shawl.qiu'
    •     end function
    •     
    •     private function binToStr(bin)
    •     '二进制转为 string (bmp|gif|png)
    •         dim i, iByt, sByt, bLen:bLen=lenB(bin)
    •         for i=1 to bLen
    •             sByt=midB(bin,i,1):iByt=ascB(sByt)
    •             if iByt<128 then
    •                 binToStr=binToStr&chr(iByt)
    •             else:i=i+1
    •                 if i<=bLen then binToStr=binToStr&chr(ascW(sByt&sByt))
    •             end if
    •         next 'shawl.qiu'
    •     end function
    • %>

    • 2. 参考文献
      PNG File Format Summary
      URL:  
      http://www.fileformat.info/format/png/

      3. 预览
      png file info:

      #2-4/3 Header Signature: PNG
      #12-16/4 First chunk(IHDR): IHDR
      #17-20/4 Width: 120
      #21-24/4 Height: 146
      #25-25/1 Bit depth: 8
      #26-26/1 ColorType: 3
      #27-27/1 Compression method: 0
      #28-28/1 Filter method: 0
      #29-29/1 Interlace method: 0


      附: 测试图片 
      gi_photo

      ASP adodb.stream 取 .png 图片完整文件头信息


      页面地址是:http://www.luffyes.com/articleview/2006-9-20/article_view_335.htm
    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值