..:: MX Studio Fóruns ::..: Lendo as Dimensões de uma imagem - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Lendo as Dimensões de uma imagem

#1 User is offline   xanburzum 

  • Group: Administrador
  • Posts: 2077
  • Joined: 04-November 08

Posted 27 February 2010 - 03:28 PM

CÓDIGO
<%
Dim Width
Dim Height
Dim Path

Width = -1
Height = -1

Path = Request.QueryString("Path")
If Path = "" Then Path = "xan.gif"
Call LerImg(Path)

%>
<HTML>
    <HEAD>
        <TITLE>Lendo as Dimensões </TITLE>
    </HEAD>
    <BODY>
        <H1>Lendo as Dimensões</H1>
        <P>
            Esta demonstração vai
ler um arquivo GIF e retornar as
dimensões.
        </P>
        <FORM>
            <INPUT name="Path" value="<%=Path%>"><BR>
            <INPUT type="Submit" value="Get Dimensions">
        </FORM>
        Width: <%=Width%><BR>
        Height: <%=Height%><BR>
        <BR>
    
    </BODY>
</HTML>
<%
Sub LerImg(ByRef pStrPath)
    
    Dim lObjFSO
    Dim lStrData
    Dim lStrPath
'aqui verificamos uma imagem com extensão .gif
    If Not UCase(Right(pStrPath, 4)) = ".GIF" Then Exit Sub
    
    If InStr(1, pStrPath, "\") = 0 Then
        lStrPath = Server.MapPath(pStrPath)
    Else
        lStrPath = pStrPath
    End If
        
    Set lObjFSO = Server.CreateObject("Scripting.FileSystemObject")
    If lObjFSO.FileExists(lStrPath) Then
        lStrData = lObjFSO.OpenTextFile(lStrPath).ReadAll()
    End If
    Set lObjFSO = Nothing
    If Len(lStrData) < 10 Then Exit Sub        
    If Not Left(lStrData, 3) = "GIF" Then Exit Sub
    Width = CInt("&h" & _
        Right("0" & Hex(Asc(Mid(lStrData, 8))), 2) & _
        Right("0" & Hex(Asc(Mid(lStrData, 7))), 2) _
        )
            
    Height = CInt("&h" & _
        Right("0" & Hex(Asc(Mid(lStrData, 10))), 2) & _
        Right("0" & Hex(Asc(Mid(lStrData, 9))), 2) _
        )
End Sub
%>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)