<%
Classe imgwhinfo '' 获取图片宽度和高度的类 , 支持 jpg , gif , png , bmp
ASO DIM
Private Sub class_inialize
Set aso = server.createObject ("adodb.stream")
Aso.mode = 3
Aso.type = 1
Aso.open
Sub-Sub
Sous-classe privée_terminée
Err.Clear
Set ASO = Rien
Sub-Sub
Fonction privée bin2str (bin)
Dim I, str
Pour i = 1 à Lenb (poubelle)
CLOW = midb (bac, i, 1)
Si ASCB (CLOW) <128 alors
Str = str & chr (ascb (Clow))
Autre
I = i + 1
Si je <= Lenb (bin) alors str = str & chr (ascw (midb (bin, i, 1) & clow)))
Terminer si
Suivant
Bin2str = str
Fonction finale
Fonction privée num2str (num, base, objectif)
Dim retr
Ret = ""
While (num> = base)
Ret = (num mod base) & ret
Num = (num - num mod base) / base
Se promener
Num2str = droite (String (Lens, "0") & num & ret, Lens)
Fonction finale
Fonction privée str2num (str, base)
Dim ret, i
Ret = 0
Pour i = 1 à Len (str)
Ret = ret * base + cint (mid (str, i, 1))
Suivant
Str2num = ret
Fonction finale
Fonction privée binval (poubelle)
Dim ret, i
Ret = 0
Pour i = Lenb (bin) à 1 étape -1
Ret = ret * 256 + ascb (midb (bin, i, 1))
Suivant
Binval = ret
Fonction finale
Fonction privée binval2 (bac)
Dim ret, i
Ret = 0
Pour i = 1 à Lenb (poubelle)
Ret = ret * 256 + ascb (midb (bin, i, 1))
Suivant
Binval2 = ret
Fonction finale
Fonction privée getImageSize (filespec)
Bflag sombre
Dim Ret (3)
Aso.loadFromfile (filespec)
bflag = aso.read (3)
Sélectionnez Case Hex (Binval (BFLAG))
Cas "4e5089":
Aso.read (15)
ret (0) = "png"
ret (1) = binval2 (aso.read (2))
Aso.read (2)
ret (2) = binval2 (aso.read (2))
Cas "464947":
Aso.read (3)
ret (0) = "gif"
ret (1) = binval (aso.read (2))
ret (2) = binval (aso.read (2))
Cas "535746":
Aso.read (5)
bindata = aso.read (1)
SCONV = num2str (ASCB (bindata), 2, 8)
nbits = str2num (gauche (SCONV, 5), 2)
SCONV = MID (SCONV, 6)
Tandis que (Len (SCONV) <nbits * 4)
bindata = aso.read (1)
SCONV = SCONV & NUM2STR (ASCB (BINDATA), 2, 8)
Se promener
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)
Cas "ffd8ff":
Faire
Do: p1 = binval (aso.read (1)): boucle tandis que p1 = 255 et non aso.eos
Si p1> 191 et p1 <196, alors sortez faire else aso.read (binval2 (aso.read (2)) - 2)
Do: p1 = binval (aso.read (1)): boucle tandis que p1 <255 et non aso.eos
Boucle tandis que vrai
Aso.read (3)
ret (0) = "jpg"
ret (2) = binval2 (aso.read (2))
ret (1) = binval2 (aso.read (2))
Cas aille:
Si vous êtes laissé (bin2str (bflag), 2) = "bm" alors
Aso.read (15)
ret (0) = "bmp"
ret (1) = binval (aso.read (4))
ret (2) = binval (aso.read (4))
Autre
ret (0) = ""
Terminer si
Fin de sélection
ret (3) = "width =" "" & ret (1) & "" "" & ret (2) & "" ""
getImageSize = ret
Fonction finale
Fonction publique IMGW (IMGPATH)
Dim fso, imgfile, filext, arrond
Set fso = server.createObject ("scripting.filesystemObject")