为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

asp获取图片高度和宽度

2017-11-11 7页 doc 21KB 6阅读

用户头像

is_531654

暂无简介

举报
asp获取图片高度和宽度asp获取图片高度和宽度 获取图片的宽度和高度 =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...
asp获取图片高度和宽度
asp获取图片高度和宽度 获取图片的宽度和高度 <% IMGPath="upload/"&pic1 Set PP=New ImgWHInfo W = PP.imgW(Server.Mappath(IMGPath)) H = PP.imgH(Server.Mappath(IMGPath)) Set pp=Nothing '类代码 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)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 %>
/
本文档为【asp获取图片高度和宽度】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索