判断gif图像尺寸的方法

博客介绍了一种根据GIF图像格式判断其尺寸的方法,给出了HTML表单用于上传GIF图片的代码,以及ASP代码来处理上传数据,通过解析二进制数据获取图像的版本、尺寸和颜色等信息,并输出图像大小。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

判断gif图像尺寸的方法
http://www.tongyi.net  出处:51study.com    点击:2127  

这里是我根据gif图像格式想出来的判断gif图像尺寸的方法,请大家给点意见
up.htm
<html>
<body>
<form action="up.asp" ENCTYPE="multipart/form-data"  method="post">
<table border=0 width=100% cellspacing="0">
  <tr>
    <td width="30%">请选择您要上传的gif图片:</td>
    <td width="70%"><input type="file" name="pic" style="font-size:10pt;"></td>
  </tr>
</table>     
<p align="center"><input type="submit" value="提交" style="font-size:9pt;background-color:#54B060;color:white;">
</form>
</body>
</html>


up.asp

<%
    
    FormSize = Request.TotalBytes
    FormData = Request.BinaryRead( FormSize )
    
    bncrlf=chrb(13) & chrb(10)
    divider=leftb(formdata,instrb(formdata,bncrlf)-1)
    datastart=instrb(formdata,bncrlf & bncrlf)+4
    dataend=instrb(datastart+1,formdata,divider)-datastart
    Image=midb(formdata,datastart,dataend)

    head_version = Ascb( midb( Image,1,3 ) )
    head_subversion = Ascb( midb( Image,4,3 ) )

    head_width_l = Ascb( midb( Image,7,1 ) )
    head_width_h = Ascb( midb( Image,8,1 ) )

    head_height_l = Ascb( midb( Image,9,1 ) )
    head_height_h = Ascb( midb( Image,10,1 ) )

    head_colors = Ascb( midb( Image, 11, 1 ) )

    head_width_h = head_width_h * 256
    
    head_height_h = head_height_h * 256
    
    
    head_colors = head_colors And &H07

    Response.Write "图像大小为" & head_width_h + head_width_l & "x" & head_height_h + head_height_l _
        & "x" &  2^( head_colors + 1 )
    

%> 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值