<%
Klasse imgWHINFO '' 获取图片宽度和高度的类 , 支持 JPG , gif , png , bmp
Dim Aso
Private sub class_initialize
Setzen Sie ASO = Server.CreateObject ("adodb.stream").
ASO.MODE = 3
ASO.Type = 1
ASO.Open
Ende sub
Private sub class_terate
Err.clear
Setzen Sie ASO = nichts
Ende sub
Private Funktion Bin2str (Bin)
Dim i, str
Für i = 1 bis lenb (bin)
Clow = Midb (bin, i, 1)
Wenn ASCB (Clow) <128 dann
STR = STR & CHR (ASCB (Clow))
Anders
I = i+1
Wenn ich <= lenb (bin) dann Str = str & chr (ASCW (MIDB (Bin, I, 1) & Clow))
Ende wenn
Nächste
Bin2str = str
Endfunktion
Private Funktion Num2str (Num, Basis, Linse)
Dim Ret
Ret = "" "
While (num> = base)
Ret = (num mod base) & ret
Num = (num - num mod base)/base
Wend
Num2str = rechts (String (Linse, "0") & Num & Ret, Linse)
Endfunktion
Private Funktion Str2num (STR, Basis)
Dim Ret, ich
Ret = 0
Für i = 1 bis len (str)
Ret = ret *base + cint (mid (str, i, 1))
Nächste
Str2num = ret
Endfunktion
Private Funktion Binval (Bin)
Dim Ret, ich
Ret = 0
Für i = lenb (bin) bis 1 Schritt -1
Ret = ret *256 + ascb (Midb (bin, i, 1))
Nächste
Binval = ret
Endfunktion
Private Funktion Binval2 (Bin)
Dim Ret, ich
Ret = 0
Für i = 1 bis lenb (bin)
Ret = ret *256 + ascb (Midb (bin, i, 1))
Nächste
Binval2 = ret
Endfunktion
Private Funktion getImageSize (filespec)
Dim Bflag
Dim Ret (3)
ASO.LOADFROMFILE (filespec)
Bflag = ASO.Read (3)
Wählen Sie Case Hex (Binval (Bflag))
Fall "4E5089":
ASO.Read (15)
ret (0) = "png"
Ret (1) = Binval2 (ASO.Read (2))
ASO.Read (2)
Ret (2) = Binval2 (ASO.Read (2))
Fall "464947":
ASO.Read (3)
ret (0) = "gif"
ret (1) = binval (aso.read (2))
ret (2) = binval (aso.read (2))
Fall "535746":
ASO.Read (5)
bindata = aso.read (1)
SCONV = Num2str (ASCB (Bindata), 2, 8)
NBits = str2num (links (SCONV, 5), 2)
sconv = mid (sconv, 6)
While (len (sconv) <Nbits*4)
bindata = aso.read (1)
SCONV = SCHONV & NUM2STR (ASCB (BINDATA), 2, 8)
Wend
ret (0) = "swf"
ret (1) = int (ABS (STR2NUM (MID (SCHONV), 1*NBITS+1, NBITS), 2) -SR2NUM (MID (SCHONV, 0*NBITS+1, NBITS), 2))/20)
ret (2) = int (ABS (str2num (Mid (SCONV, 3*NBits+1, NBit), 2) -Str2num (MID (SCHONV, 2*NBITS+1, NBITS), 2))/20)
Fall "FFD8ff":
Tun
Do: p1 = binval (ASO.Read (1)): Schleife während P1 = 255 und nicht ASO.eos
Wenn P1> 191 und P1 <196, dann beenden Sie sonst ASO.Read (Binval2 (ASO.Read (2))-2)
Do: p1 = binval (ASO.Read (1)): Schleife während P1 <255 und nicht ASO.eos
Schleife während wahr
ASO.Read (3)
ret (0) = "jpg"
Ret (2) = Binval2 (ASO.Read (2))
Ret (1) = Binval2 (ASO.Read (2))
Fall sonst:
Wenn Sie links (bin2str (bflag), 2) = "Bm" dann
ASO.Read (15)
ret (0) = "BMP"
ret (1) = binval (aso.read (4))
ret (2) = binval (aso.read (4))
Anders
ret (0) = ""
Ende wenn
Ende auswählen
ret (3) = "width =" "" "& ret (1) &" "" "& ret (2) &" "" ""
getImagesize = ret
Endfunktion
Öffentliche Funktion IMGW (IMGPath)
Dim FSO, ImgFile, Fileext, arr
Setzen Sie fso = server.createObject ("scripting.FilesSystemObject").