日期:2010-08-25  浏览次数:20969 次

这是动网论坛上一个朋友写的

<% 
imgpath="default_22.gif"

 set  pp=new  imgInfo 
 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

Class  imgInfo 
 dim  aso 
 Private  Sub  Class_Initialize 
   set  aso=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 
   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 
   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 
   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  ret(3) 
   aso.LoadFromFile(filespec) 
   bFlag=aso.read(3) 
   select  case  hex(binVal(bFlag)) 
   case  "4E5089":