请问,如何才能获取bmp等类型图片的高和宽呢?

xunua 2005-11-07 09:50:57
请问,如何才能获取bmp等类型图片的高和宽呢?例如bmp,png等等
从前都是用aspjpeg组件获取图片高和宽,它可以获取jpg和gif图片的高宽,但是它对bmp等其他格式的图片无效。
...全文
150 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xunua 2005-11-09
  • 打赏
  • 举报
回复
不行啊, satans18给的类对于一些比较大的bmp图片会报错,宽度和高度的值会很大,上亿,出现溢出错误。
xunua 2005-11-09
  • 打赏
  • 举报
回复
顶一下
xunua 2005-11-07
  • 打赏
  • 举报
回复
谢谢satans18
eglic发的是什么啊?
vulcan 2005-11-07
  • 打赏
  • 举报
回复
楼上的正解!
是是非非 2005-11-07
  • 打赏
  • 举报
回复
涨性欲分的唯一途径:

提交FAQ并通过审核~
xunua 2005-11-07
  • 打赏
  • 举报
回复
解释一下
N年前刚用CSDN,很多功能不知道,断断续续的上,有些帖子没结,结果时间一长被强制结帖了,所以性欲很低。现在无论怎样及时结帖我的性欲都无法回升,CSDN怎么搞得啊,不给我提升性欲的机会啊,作为一个男人,性欲78,多丢人啊。
to CSDN administrator:为什么现在及时结帖性欲也无法提升?!?!?!?
是是非非 2005-11-07
  • 打赏
  • 举报
回复
Dim img : Set img=LoadPicture(Server.MapPath(".") & "\200542617470.jpg")
Response.Write img.Width/26.4583333333333
Response.Write "<br />"
Response.Write img.Height/26.4583333333333
Set img=Nothing
satans18 2005-11-07
  • 打赏
  • 举报
回复
晕 楼主的性欲怎么这么低
satans18 2005-11-07
  • 打赏
  • 举报
回复
<%
Class ImgWHInfo ''获取图片宽度和高度的类,支持JPG,GIF,PNG,BMP
Dim ASO
Private Sub Class_Initialize
Set ASO=Server.CreateObject("ADODB.Stream")
ASO.Mode=3
ASO.Type=1
ASO.Open
End Sub
Private Sub Class_Terminate
Err.Clear
Set ASO=Nothing
End Sub

Private Function Bin2Str(Bin)
Dim I, Str
For I=1 To LenB(Bin)
clow=MidB(Bin,I,1)
If ASCB(clow)<128 Then
Str = Str & Chr(ASCB(clow))
Else
I=I+1
If I <= LenB(Bin) Then Str = Str & Chr(ASCW(MidB(Bin,I,1)&clow))
End If
Next
Bin2Str = Str
End Function

Private Function Num2Str(Num,Base,Lens)
Dim Ret
Ret = ""
While(Num>=Base)
Ret = (Num Mod Base) & Ret
Num = (Num - Num Mod Base)/Base
Wend
Num2Str = Right(String(Lens,"0") & Num & Ret,Lens)
End Function

Private Function Str2Num(Str,Base)
Dim Ret,I
Ret = 0
For I=1 To Len(Str)
Ret = Ret *base + Cint(Mid(Str,I,1))
Next
Str2Num=Ret
End Function

Private Function BinVal(Bin)
Dim Ret,I
Ret = 0
For I = LenB(Bin) To 1 Step -1
Ret = Ret *256 + AscB(MidB(Bin,I,1))
Next
BinVal=Ret
End Function

Private Function BinVal2(Bin)
Dim Ret,I
Ret = 0
For I = 1 To LenB(Bin)
Ret = Ret *256 + AscB(MidB(Bin,I,1))
Next
BinVal2=Ret
End Function

Private Function GetImageSize(filespec)
Dim bFlag
Dim Ret(3)
ASO.LoadFromFile(filespec)
bFlag=ASO.Read(3)
Select Case Hex(binVal(bFlag))
Case "4E5089":
ASO.Read(15)
ret(0)="PNG"
ret(1)=BinVal2(ASO.Read(2))
ASO.Read(2)
ret(2)=BinVal2(ASO.Read(2))
Case "464947":
ASO.read(3)
ret(0)="gif"
ret(1)=BinVal(ASO.Read(2))
ret(2)=BinVal(ASO.Read(2))
Case "535746":
ASO.read(5)
binData=ASO.Read(1)
sConv=Num2Str(ascb(binData),2 ,8)
nBits=Str2Num(left(sConv,5),2)
sConv=mid(sConv,6)
While(len(sConv)<nBits*4)
binData=ASO.Read(1)
sConv=sConv&Num2Str(AscB(binData),2 ,8)
Wend
ret(0)="SWF"
ret(1)=Int(Abs(Str2Num(Mid(sConv,1*nBits+1,nBits),2)-Str2Num(Mid(sConv,0*nBits+1,nBits),2))/20)
ret(2)=Int(Abs(Str2Num(Mid(sConv,3*nBits+1,nBits),2)-Str2Num(Mid(sConv,2*nBits+1,nBits),2))/20)
Case "FFD8FF":
Do
Do: p1=binVal(ASO.Read(1)): Loop While p1=255 And Not ASO.EOS
If p1>191 And p1<196 Then Exit Do Else ASO.read(binval2(ASO.Read(2))-2)
Do:p1=binVal(ASO.Read(1)):Loop While p1<255 And Not ASO.EOS
Loop While True
ASO.Read(3)
ret(0)="JPG"
ret(2)=binval2(ASO.Read(2))
ret(1)=binval2(ASO.Read(2))
Case Else:
If left(Bin2Str(bFlag),2)="BM" Then
ASO.Read(15)
ret(0)="BMP"
ret(1)=binval(ASO.Read(4))
ret(2)=binval(ASO.Read(4))
Else
ret(0)=""
End If
End Select
ret(3)="width=""" & ret(1) &""" height=""" & ret(2) &""""
getimagesize=ret
End Function

Public Function imgW(IMGPath)
Dim FSO,IMGFile,FileExt,Arr
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If (FSO.FileExists(IMGPath)) Then
Set IMGFile = FSO.GetFile(IMGPath)
FileExt=FSO.GetExtensionName(IMGPath)
Select Case FileExt
Case "gif","bmp","jpg","png":
Arr=GetImageSize(IMGFile.Path)
imgW = Arr(1)
End Select
Set IMGFile=Nothing
Else
imgW = 0
End If
Set FSO=Nothing
End Function

Public Function imgH(IMGPath)
Dim FSO,IMGFile,FileExt,Arr
Set FSO = server.CreateObject("Scripting.FileSystemObject")
If (FSO.FileExists(IMGPath)) Then
Set IMGFile = FSO.GetFile(IMGPath)
FileExt=FSO.GetExtensionName(IMGPath)
Select Case FileExt
Case "gif","bmp","jpg","png":
Arr=getImageSize(IMGFile.Path)
imgH = Arr(2)
End Select
Set IMGFile=Nothing
Else
imgH = 0
End If
Set FSO=Nothing
End Function
End Class

'IMGPath="logo.gif"
'Set PP = New ImgWHInfo
'W = PP.imgW(Server.Mappath(IMGPath))
'H = PP.imgH(Server.Mappath(IMGPath))
'Set pp = Nothing
'Response.Write("<img src=''"&IMGPath&"'' border=0><br>宽:"&W&";高:"&H)
%>
satans18 2005-11-07
  • 打赏
  • 举报
回复

imgwidth=document.getElementByID("images").width;
imgheight=document.getElementByID("images").height;

vulcan 2005-11-07
  • 打赏
  • 举报
回复
用JS客户端判断一下,再提交就可以了

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧