<% Class imgwhinfo 'Get image width and height class, support JPG, GIF, PNG, BMP DIM ASO Private Sub class_initialize set aso = server.createObject ("AdoDb.Stream") aso.mode = 3 aso.type = 1 ASO .Openate 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 dend bin2str = str dend binction 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 (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 GetImages (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)
Binval2 (ASO.READ (2)) Case Else: if Left (Bin2Str (BFLLAG), 2) = "BM" THEN ASO.READ (15) RET (0) = "BMP" RET (1) = binval (ASO. READ (4)) RET (2) = binval (ASO.READ (4)) Else Ret (0) = "" "" 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 = getImages (IMGFile .Path) IMGW = arr (1) end select set imgfile = Nothing else imgw = 0 end if set fso = Nothing end f unction 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 .GextensionName (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 classimgpath = "test.jpg"
Set pp = new imgwhinfo w = pp.imgw (server.mappath (imgpath)) h = pp.imgh (server.mappath (imgpath)) set pp = Nothing response.write ("
Wid: "& W &"; High: "& H)%>