<% IMGPATH = "default_22.jpg"
Set pp = new imginfo w = pp.imgw (server.mappath (imgpath)) h = pp.imgh (server.mappath (imgpath)) set pp = Nothing response.write "
Wide: "& W &"; High: "& 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 TEN 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 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 RET 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 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": 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)
"" Height = "" "" "" "" " THEN SET F1 = fso1.Getfile (PIC_PATH) EXT = fso1.getextensionName (PIC_PATH) SELECT CASE EXT CASE "GIF", "BMP", "JPG", "PNG": arr = getImagesize (f1.path) IMGW = Arr ( 1) end select Set f1 = nothing else imgW = 0 End if Set fso1 = nothing End Function Public Function imgH (pic_path) Set fso1 = server.CreateObject ( "Scripting.FileSystemObject") If (fso1.FileExists (pic_path)) Then Set F1 = fso1.Getfile (PIC_PATH) EXT = fso1.getextensionName (PIC_PATH) Select Case Ext Case "GIF", "BMP", "JPG", "PNG": arr = getImagesize (f1.path) IMGH = arr (2) End SELECT SET F1 = Nothing else IMGH = 0 end if set fso1 = Nothing end function end class%>