<%
'' ::: :::::::::::::::::::::: :::::::::::::::::
'' ::: :::::::::::::::::::::: :::::::::::::::::
'' ::: BMP, GIF, JPG and PNG :::
'' ::: :::::::::::::::::::::: :::::::::::::::::
'' ::: :::::::::::::::::::::: :::::::::::::::::
'' ::: ::::
'' ::: this function gets a specified number of bytes from any :::
'' ::: File, Starting At the Offset (Base 1) :::
'' ::: ::::
'' :::Pased: :::
'' ::: flnm => filespec of file to read :::
'' ::: Offset => Offset at Which to Start Reading :::
'' ::: Bytes => How much bytes to read :::
'' ::: ::::
'' ::: :::::::::::::::::::::: :::::::::::::::::
Function getBytes (flnm, offset, bytes)
DIM OBJFSO
DIM Objftemp
DIM ObjTextStream
Dim lngsize
ON Error ResMe next
Set objfso = creteObject ("scripting.filesystemobject")
'' First, We get the filesis
Set objftemp = objfso.getfile (flnm)
LNGSIZE = Objftemp.size
Set objftemp = Nothing
FsoForReading = 1
Set objTextStream = objfso.opentextfile (flnm, fsoforreading)
IF offset> 0 THEN
Strbuff = ObjtextStream.read (Offset - 1)
END IF
iftes = -1 Then '' get all!
GetBytes = ObjTextStream.read (LNGSIZE) '' Readall
Else
GetBytes = ObjTextStream.read (bytes)
END IF
ObjtextStream.close
Set objtextStream = Nothing
Set objfso = Nothing
END FUNCTION
'' ::: :::::::::::::::::::::: :::::::::: '' ::: :::
'' ::: Functions to Convert Two bytes to a Numeric Value :::
'' ::: (Both Little-endian and big-endian) :::
'' ::: ::::
'' ::: :::::::::::::::::::::: :::::::::::::::::
Function LNGCONVERT (STRTEMP)
LNGCONVERT = CLNG (ASC (LEFT (STRTEMP, 1)) ((ASC (Right (strTemp, 1)) * 256))))))
END FUNCTION
Function LNGCONVERT2 (STRTEMP)
LNGCONVERT2 = ClNG (ASC (Right (strTemp, 1)) ((ASC (Left (Strtemp, 1)) * 256)))))))))
END FUNCTION
'' ::: :::::::::::::::::::::: :::::::::::::::::
'' ::: ::::
'' ::: this function does Most of the real work. It will attempt :::
'' ::: r r f, regardless of the extension, and will :::
'' ::: Identify if it is a graphical image. :::
'' ::: ::::
'' :::Pased: :::
'' ::: flnm => filespec of file to read :::
'' ::: width => width of image :::
'' ::: Height => Height of Image :::
'' ::: Depth => Color Depth (in Number of Colors) :::
'' ::: StrimageType => Type of Image (E.G. GIF, BMP, etc.) :::
'' ::: ::::
'' ::: :::::::::::::::::::::: :::::::::::::::::
Function GFXSPEX (FLNM, Width, Height, Depth, StrimageType)
DIM STRPNG
DIM STRGIF
DIM STRBMP
DIM STRTYPE
Strtype = ""
StrimageType = "(unknown"
GFXSPEX = FALSE
Strpng = CHR (137) & chr (80) & chr (78)
Strgif = "gif"
StrBMP = CHR (66) & chr (77)
Strtype = getBytes (flnm, 0, 3)
IF strType = strgif kilns '' is gif
StrimageType = "gif"
Width = LNGCONVERT (GetBytes (FLNM, 7, 2))
Height = LNGCONVERT (GetBytes (FLNM, 9, 2))
Depth = 2 ^ ((ASC (Gettes (FLNM, 11, 1)) and 7) 1)
GFXSPEX = TRUE
Elseif Left (Strtype, 2) = Strbmp Then '' IS BMP
StrimageType = "BMP"
Width = LNGCONVERT (GetBytes (FLNM, 19, 2))
Height = LNGCONVERT (GetBytes (FLNM, 23, 2))
Depth = 2 ^ (ASC (GetBytes (FLNM, 29, 1))))
GFXSPEX = TRUE
Elseif Strtype = Strpng Then '' IS PNG
StrimageType = "PNG"
Width = LNGCONVERT2 (GetBytes (FLNM, 19, 2))
Height = LNGCONVERT2 (GetBytes (FLNM, 23, 2))
Depth = GetBytes (flnm, 25, 2)
SELECT CASE ASC (Right (depth, 1))
Case 0
DEPTH = 2 ^ (ASC (Left (depth, 1))))
GFXSPEX = TRUE
Case 2
DEPTH = 2 ^ (ASC (Left (depth, 1)) * 3)
GFXSPEX = TRUE
Case 3
DEPTH = 2 ^ (ASC (Left (depth, 1))) '' 8
GFXSPEX = TRUE
Case 4
DEPTH = 2 ^ (ASC (Left (depth, 1)) * 2)
GFXSPEX = TRUE
Case 6
DEPTH = 2 ^ (ASC (Left (depth, 1)) * 4)
GFXSPEX = TRUE
Case Else
DEPTH = -1
End SELECT
Else
Strbuff = getBytes (flnm, 0, -1) '' Get Alltes from File
LNGSIZE = LEN (STRBUFF)
FLGFOUND = 0
STRTARGET = CHR (255) & chr (216) & chr (255)
FLGFOUND = INSTR (Strbuff, Strtarget)
IF flground = 0 THEN
EXIT FUNCTION
END IF
StrimageType = "jpg"
LNGPOS = flgfound 2
ExitLoop = falsedo while exitLoop = false and lngpos Do While ASC (MID (Strbuff, LNGPOS, 1) = 255 and lngpos LNGPOS = LNGPOS 1 loop IF ASC (MID (Strbuff, LNGPOS, 1)) <192 or ASC (MID (Strbuff, LNGPOS, 1)> 195 THEN LNGMARKERSIZE = LNGCONVERT2 (MID (Strbuff, LNGPOS 1, 2)) LNGPOS = LNGPOS LNGMARKERSIZE 1 Else ExitLoop = true END IF loop '' ' IF exitloop = false kil Width = -1 HEIGHT = -1 DEPTH = -1 Else HEIGHT = LNGCONVERT2 (MID (Strbuff, LNGPOS 4, 2)) Width = LNGCONVERT2 (MID (StrBuff, LNGPOS 6, 2)) Depth = 2 ^ (ASC (MID (Strbuff, LNGPOS 8, 1)) * 8) GFXSPEX = TRUE END IF END IF END FUNCTION '' ::: :::::::::::::::::::::: ::::::::::::::::::: '' ::: Test Harness ::: '' ::: :::::::::::::::::::::: ::::::::::::::::::: '' To test, we'll Just Try to show all files with a .gif extension in the root of c: Set objfso = creteObject ("scripting.filesystemobject") Set objf = objfso.getfolder ("c: /") Set objfc = Objf.files Response.write "