AdoDb.stream gets the high and wide image

zhaozj2021-02-16  125

AdoDb.stream gets the high and wide image

Upload images or show SWFs, I hope to get its height and width.

Basic principle uses the adoDb.stream read binary then parsing, then returns a number of first elements for the first element (BMP JPG PNG GIF SWF) The second element is the width {width} The third element is high {Height} fourth Element is width = {width}, height = {height} character string

Class Qswhimgdim asoPrivate Sub Class_initializset ASO = CREATEOBJECT ("AdoDb.Stream") aso.mode = 3 asbo.type = 1 aso.open end subprivate sub coplass_terminate set ASO = Nothingend sub

Private function bin2str (bin) DIM I, Strfor I = 1 to lenb (bin) CLOW = MIDB (BIN, I, 1) IF ASCB (CLOW) <128 Thenstr = STR & CHR (ASCB (CLOW) ELSEI = i 1IF i <= lenb (bin) THEN STR = STR & CHR (ASCW (MIDB (BIN, I, 1) & CLOW) end ifnext bin2str = strend function

Private function Num2Str (NUM, BASE, LENS) 'qiushuiwuhen (2002-8-12) DIM RETRET = "" While (NUM> = Base) RET = (Num MOD BASE) & RetNum = (Num - Num MOD BASE) / BaseWendNum2Str = Right (String (Lens, "0") & NUM & RET, LENS) End Function

Private function str2num (str, base) 'qiushuiwuhen (2002-8-12) DIM RETRET = 0for i = 1 to LEN (STR) RET = RET * BASE CINT (MID (STR, I, 1)) NextStr2Num = Retend FUNCTION

Private function binval (bin) 'qiushuiwuhen (2002-8-12) DIM RETRET = 0for i = lenb (bin) to 1 step -1ret = RET * 256 ASCB (MIDB (BIN, I, 1)) Nextbinval = Retend Function

Private function binval2 (bin) 'qiushuiwuhen (2002-8-12) DIM RETRET = 0for i = 1 to lenb (bin) RET = RET * 256 ASCB (MIDB (BIN, I, 1)) Nextbinval2 = Retend Function

Function GetImageSize (filespec) 'QiushuiWuhen (2002-9-3) 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 191 and P1 <196 Then Exit do else aso.read (binval2 (ass (2)) - 2) DO: P1 = binval (aso.read (1) : Loop While P1 <255 and not aso.Eosloop While Trueaso.read (3) RET (0) = "JPG" RET (2) = bi Nval2 (ASO.READ (2)) RET (1) = binval2 (ASO.READ (2)) Case Else: if Left (Bin2Str (BFLAG), 2) = "BM" Thenaso.read (15) Ret (0) = "BMP" RET (1) = binval (ASO.READ (4)) RET (2) = binval (aso.read (4)) Elseret (0) = "" Endness Selectret (3) = "width =" "" & ret (1) & "" Height = "" "" "" "" "" GetImageSize = Retend functionion Class use example (width of all images in a directory): set qswh = new qswhimg

SET FSO = CreateObject ("scripting.filesystemObject") set f = fsgetfolder (Server.mappath (")) SET FC = F.FilesFor Each F1 in fcext = fso.GETEXTENSIONNAME (F1.Path) Select Case Extcase GIF "," BMP "," JPG "," PNG ": arr = qswh.getiMageSize (f1.path) response.write"
"& arr (0) &" & arr (3) & ":" & f1.name & "Width:" & Arr (1) & "Height:" & Arr (2) Case "SWF" arr = qswh.getiMagesize (f1.path) response.write "
" & arr (0 ) & "& arr (3) &": "& f1.name &" width: "& arr (1) &" height: "& arr (2) end selectnextset fc = nothingset f = nothingset fso = NothingSet qswh = Nothing

PS. The reference of the SWF section is provided by blue,: P

Blue supplement: Since FlashMX uses a new compressed format SWF, the long width of the SWF file in the flashmx compression format does not accurately, the solution is being studied.

转载请注明原文地址:https://www.9cbs.com/read-8360.html

New Post(0)