MrNik
Starting Member
Italy
49 Posts |
Posted - 07 September 2002 : 06:48:58
|
I have this function :
<% ' resample and proportinalize image
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")
On Error Resume Next
Set ts = fso.OpenTextFile(Server.MapPath("/forum/" & i_sFilename))
If Err.Number <> 0 Then Err.Clear Set ts = fso.OpenTextFile("/forum/noavatar.gif") End if
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
maxwidth = 64 maxheight = 100 if o_nWidth > maxwidth or o_nHeight > maxheight then if o_nWidth > maxwidth then o_nHeight = cInt(o_nHeight * maxwidth/o_nWidth) o_nWidth = maxwidth if (o_nHeight > maxheight) then o_nWidth = cInt(o_nWidth * maxheight/o_nHeight) o_nHeight = maxheight end if elseif o_nHeight > maxheight then o_nWidth = cInt(o_nWidth * maxheight/o_nHeight) o_nHeight = maxheight if (o_nWidth > maxwidth) then o_nHeight = cInt(o_nHeight * maxwidth/o_nWidth) o_nWidth = maxwidth end if end if end if o_nText = " X " response.write " width=""" & o_nWidth & """ height=""" & o_nHeight & """" response.write " title=""" & o_nWidth & o_nText & o_nHeight & """" Set ts = Nothing Set fso = Nothing End Sub
%>
in topic.asp I have the following part of code :
Response.Write " </p>" & vbNewLine if Reply_MemberAvatar <> "noavatar.gif" then response.write" <img src=""" & Reply_MemberAvatar & """ width=""" & intAvatarWidth & """ height=""" & intAvatarHeight & """ border=""" & intAvatarBorder & """>" end if response.write " <p><font color=""" & strForumFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """><small>" & Reply_MemberCountry & "</small></font><br />" & vbNewLine & _
|
|
|