No Components | no component <%
Class Imgwhinfo ' Get a picture of the width and height of classes, support 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":
Todo
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)