Thank you very much, I'm much obliged for the help.
I've changed these a bit, and here's the final product I'm using:
Sub GetPicFileInfo( i_sFilename, o_PicType, o_nWidth, o_nHeight )
i_sFilename = replace(i_sFilename, "/", "\", 1, -1, 1)
o_PicType = ""
o_nWidth = 0
o_nHeight = 0
Dim fso, ts
Dim GIF_MARKER, JPG_MARKER
GIF_MARKER = "GIF8"
JPG_MARKER = Chr(&HFF) & Chr(&HD8) & Chr(&HFF) & Chr(&HE0)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("C:\www\someplacesomewhere.com\forums\" & i_sFilename)
On Error Resume Next
Select Case ts.Read(4)
Case GIF_MARKER
o_PicType = "GIF"
ts.Skip(2)
If Err.Number <> 0 Then
Exit Sub
End If
o_nWidth = Asc(ts.Read(1)) + ( Asc(ts.Read(1))* 256 )
o_nHeight = Asc(ts.Read(1)) + ( Asc(ts.Read(1))* 256 )
Case JPG_MARKER
o_PicType = "JPG"
Dim byteVal, bDone
bDone = False
byteVal = Asc(ts.Read(1))
Do While Not ts.AtEndOfStream And byteVal <> &HD8 And Not bDone
'look for the next marker (xFF)
Do While Not ts.AtEndOfStream And byteVal <> &HFF
byteVal = Asc(ts.Read(1))
Loop
'Get past any repeated xFF markers
Do While Not ts.AtEndOfStream And byteVal = &HFF
byteVal = Asc(ts.Read(1))
Loop
'Check out the marker
'if this is the width/height section then read the values
If ((byteVal >= &HC0) And (byteVal <= &HC3)) Then
ts.Skip(3)
If Err.Number <> 0 Then
Exit Sub
End If
If Not ts.EOF Then
o_nHeight = (Asc(ts.Read(1)) * 256) + Asc(ts.Read(1))
o_nWidth = (Asc(ts.Read(1)) * 256) + Asc(ts.Read(1))
bDone = True
End If
Else
'this is a comment or other stuff we are not interested in.
'we must read the size and then skip over this section
Dim nSectionLength
nSectionLength = (Asc(ts.Read(1)) * 256) + Asc(ts.Read(1))
'NOTE: we subtract two since from the size since we already
'are past the length bytes which are included in the size
ts.Skip(nSectionLength - 2)
byteVal = Asc(ts.Read(1))
If Err.Number <> 0 Then
Exit Sub
End If
End If
Loop
End Select
if o_nWidth > 64 or o_nHeight > 64 then
if o_nHeight > o_nWidth then
o_nWidth = cInt(o_nWidth * 64/o_nHeight)
o_nHeight = 64
else
o_nHeight = cInt(o_nHeight * 64/o_nWidth)
o_nWidth = 64
end if
end if
response.write " width=""" & o_nWidth & """ height=""" & o_nHeight & """"
Set ts = Nothing
Set fso = Nothing
End Sub
S.P.S.W. - My Forums