Ir para conteúdo
Fórum Script Brasil
  • 0

Tamanho Da Imagem


Guest Alan Hoffmeister

Pergunta

Guest Alan Hoffmeister

Olá pessoal, estou usando um código pronto em ASP (dããã) o qual organiza uma galeria de imagens para meu site. O meu problema é que eu não concigo mudar o tamanho das imagens quando ele carrega elas. Fica na resolução original, 2500x1400 por exemplo. Gostaria de saber se seria mais sensato eu redimencionar as imagens manualmente ou botar um código na página que diminua o tamanho dela..

Se a alternativa mais correta é a do código, é ai que se encontra o problema.. Eu não sei fazer...

PAra quem quizer ver o código..

<%@ LANGUAGE="VBScript"%>
<%
Option Explicit
Sub ShowCredits() %>
<!--
Online Photo Catalog VBScript v2.1
Author: Ivan Loire www.iloire.com
Copyright 2002. All rights reserved.
Released on 23/4/2002
Feel free to use this script leaving this header.
-->
<%
End Sub
'--------
'What's new in v2.0?
'1) Now this script allows comments.
' If you want to add comments for a pic, only put in the same folder of the pic a text file with your comments in it.
' The text file must have the same name of the picture and the extension : .txt.
' Ej: pic: bertin_in_the_beach.jpg; text file with comments (located in the same folder): bertin_in_the_beach.txt
'2) Cosmetic change
' Now with the folder icon


'What's new in v2.1?
'1) Allow visitor change number of pics per row.
'2) Allow visitor to enter comments (xml format)
'3) Cosmetic changes
'---------------------

'CONFIGURATION. EDIT ONLY THIS PART
Const cVirtualPath="/album/" 'where is the images folder
Const cPageTitle="Galeria" 'Page title
Const cWidthThumbnails=40 ' Thumbnail's width
Const cFirstPageText="<h3><b>Informação</b></h3><br>Selecione uma pasta da galeria ao lado. <br><br>Por favor seja paciente enquanto as imagens são carregadas. <br>Uma vez que você possa ver a miniatura, a imagem já estará disponível para acesso rápido."
Const cNumberPicturesPerRowDefault=5 'set the default number of thumbails per row.
Const WritableXMLCommentsFolder="d:\html\users\iloirecom\xml\comments\"
Const cAllowUserEnterComments=false 'allow visitor to add comments to the pics. You will need write access permit to comments file!
Const cAllowUserChangePicturePerRow=true 'allow visitor to change the number of pictures he visualize per row
'END CONFIGURATION


Dim strThispage
strThispage= Request.ServerVariables ("SCRIPT_NAME")

Sub UserCommentsEngine ()

Dim link,commentsList,objXML,comment,objXMLcomment,FileLocation
FileLocation=WritableXMLCommentsFolder & replace(request("Filename"), right(request("Filename"),4),".xml")
'FileLocation=Server.MapPath(replace(request("Item"), right(request("Item"),4),".xml"))
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
If objXML.load(Filelocation) = False Then
objXML.appendChild(objXML.createProcessingInstruction("xml","version=""1.0"""))
objXML.appendChild(objXML.createElement("comments"))
End If
link=strthispage & "?action=displayimage&Filename=" & request("Filename") & "&Item=" & request("Item")
'create html code to enter comments

if request("write")="yes" then
prt "<form method=post action=""" & link &"""><table><tr><td>"
prt "Your name/email: </td><td><input type=text name=author><br></td></tr>"
prt "<tr><td>Comments:</td><td><textarea name=text cols=20 rows=3></textarea></td></tr>"
prt "<tr><td colspan=2><input type=submit value=send></td></tr></table><hr>"
prt "</form>"
else
If len(request("text"))>0 then 'write
Set objXMLcomment = objXML.createElement("comment")
objXMLcomment.appendChild(objXML.createElement("author"))
objXMLcomment.appendChild(objXML.createElement("text"))
objXMLcomment.appendChild(objXML.createElement("date"))

objXMLcomment.childNodes(0).text = request("author")
objXMLcomment.childNodes(1).text = request("text")
objXMLcomment.childNodes(2).text = now()

objXML.documentElement.appendChild(objXMLcomment.cloneNode(True))
objXML.save(FileLocation)
Prt ("<font color=red><b>Comment added!!</b></font>")
end if
prt "<center><input value=""write comments"" type=button onclick=""location.href='" & link & "&write=yes'""></center><br>"
End if
'read
If objXML.load(FileLocation) then
prt "<div class=comments>"
Set commentsList=objXML.childnodes(1).childnodes
for each comment in commentsList
prt "<b>»</b><font class=name> " & comment.childnodes(0).text & "</font>, on <font class=date>" & comment.childnodes(2).text & "</font> said:"
prt "<blockquote><tt>" & comment.childnodes(1).text & "</tt></blockquote>"
next
prt "</div>"
end if
End Sub


Function GetComment (PictureName)
'this is the new function for the v1.1
'getting the text from the comment file (if exists)

Dim fso,FileLocation, File
Set fso = CreateObject("Scripting.FileSystemObject")

FileLocation=Server.MapPath(replace (picturename, right(picturename,4),".txt"))
If fso.FileExists(FileLocation) then
set File = fso.OpenTextFile(FileLocation, 1)
GetComment = File.ReadAll
Else
GetComment = "O autor não deichou nenhum comentário sobre essa imagem."
End If
End Function



Sub DisplayFiles(VirtualPath)
Dim File,Folder,iRow
Set folder = fs.GetFolder(Server.MapPath(VirtualPath))
Prt "<table cellpadding=0 cellspacing=0 class=tf><tr><td>"
if cAllowUserChangePicturePerRow=true then Prt("<form target=frm_files method=post action=""" & strthispage& "?action=displayfiles&item="& virtualpath & """>")
Prt ("Pasta Atual: <b>" & Folder.name & "</b></td><td>")
if cAllowUserChangePicturePerRow=true then Prt("Ajustar prévias por colunas:<input name=picsperrow type=text maxlength=2 size=2 value=""" & session("picsperrow") & """><input type=submit value=Mudar></form>")
Prt "</td><td>© <a target=_blank href=http://www.iloire.com>iloire.com</a></td></tr></table><br>"
Prt("<table class=files>")
iRow=0
For each File in folder.Files
If (lcase(right(File.path, 3)) <> "txt") and (lcase(right(File.path, 3)) <> "xml") then
If iRow=0 then Prt("<tr>")
Prt ("<td valign=middle><a target=frm_botton href=""" & strThisPage & "?action=displayimage&item=" & VirtualPath & "/" & File.Name & "&Filename="& File.Name & """><img border=0 width=""" & cstr(cWidthThumbnails) & """ src="""& VirtualPath & "/" & File.Name & """> " & File.Name & "</a></td>")
If cint(iRow)=cint(session("picsperrow")-1) then
iRow=0
Prt("</tr>")
Else
iRow=iRow+1
End If
End if
Next
if Folder.Files.Count=0 then Prt("<br><p>This folder is empty.</p>")
Prt("</table>")
End Sub


Sub Display(Item)
Dim subfolder,folder
set folder = fs.GetFolder(Server.MapPath(Item))
Prt "<ul>"
If folder.subfolders.count > 0 then
For each subfolder in folder.SubFolders
Prt "<li> <a target=frm_files href=""" & strThispage & "?action=displayfiles&item="& Item & subfolder.Name & """>" & subfolder.name &"</a>"
Display(Item & subfolder.Name &"/")
Next
End if
Prt "</ul>"
End Sub


Sub prt(strValue)
response.write(strValue) & Vbcrlf
End Sub


Sub CreateFramesBody()
Prt("<frameset rows=200,* frameborder=Yes>")
Prt("<frameset cols=200,* frameborder=Yes>")
Prt("<frameset rows=20%,* frameborder=No>")
Prt("<frame name=frm_title scrolling=No src="""& strThispage& "?action=title"">")
Prt("<frame name=frm_folders scrolling=Auto src=""" & strThispage & "?action=displayfolders"">")
Prt("</frameset>")
Prt("<frame name=frm_files src="""& strThispage& "?action=start"">")
Prt("</frameset>")
Prt("<frame name=frm_botton scrolling=Auto src="""& strThispage& "?action=empty"">")
Prt("</frameset>")

End Sub


if len(request("picsperrow")) > 0 then session("picsperrow")=cint(request("picsperrow"))
if session("picsperrow")="" then session("picsperrow")=cNumberPicturesPerRowDefault

%>
<html>
<head>
<title><%=cPageTitle%></title>
<link rel="stylesheet" href="online_photo_catalog_vbscript.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso8859-1">
</head>
<%
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

ShowCredits()

Select case request("action")
case "displayfolders"
Prt("<body class=folders><div class=folders>")
Display(cVirtualPath)
Prt("</div></body>")
case "displayfiles"
Prt("<body class=files>")
Call DisplayFiles(request("item"))
Prt("</body>")
case "start"
Prt("<body><div class=firsttext>")
Prt(cFirstPageText)
Prt("</div></body>")
case "title"
Prt("<body>")
Prt("<b>" & cPageTitle & "</b>")
Prt("</body>")
case "empty"
case "displayimage"
Prt("<body class=image>")
Prt "<div class=tf>Nome da foto: <b>" & request("Filename") & "</b> <input type=button value=Imprimir onclick=""print()""><br></div>"

Prt ("<table cellpadding=0 cellspacing=0 width=""100%""><tr><td width=20% valign=top>")
Prt("<img alt=" & request("Filename") & " src=""" & request("item") & """>")
Prt ("</td><td valign=top style=""padding:2px""><br><div class=cbody><div class=tc>Comentários do autor</div>")
Prt "<div style=padding:5px><p>" & GetComment (request("item")) & "</p></div></div><br>"
if cAllowUserEnterComments then Prt "<div class=cbody><div class=tc>Visitor Comments</div><div style=padding:5px>"
if cAllowUserEnterComments then Call UserCommentsEngine()
if cAllowUserEnterComments then Prt ("</div></div>")
Prt ("</td></tr></table>")
Prt("</body>")
case else
CreateFramesBody
End select
Set fs=nothing
%>
</html>[/codebox]

O resultado pode ser conferido em http://www.mosqueiros.com.br/album/main.asp

Grande abraço!

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,5k
×
×
  • Criar Novo...