Ho fatto sto obbrobbrio...
codice:
<%
imgTypes = array("File JPG","File GIF","File PNG")
imgPath = "/img/"
maxWidth = 200
maxHeight = 200
function resizeImgView(theImgPath, theFileName, theMaxWidth, theMaxHeight, byRef theWidth, theHeight)
dim arrHeaders(34)
set shell = server.createObject("Shell.Application")
set path = shell.namespace(server.mapPath(theImgPath))
for i = 0 to 33
arrHeaders(i) = path.getDetailsOf(path.items, i)
next
for each item in path.items
if item = thefileName then
theWidth = path.getDetailsOf(item, 27)
theWidth = cLng(left(theWidth,inStr(theWidth," ") - 1))
theHeight = path.getDetailsOf(item, 28)
theHeight = cLng(left(theHeight,inStr(theHeight," ") - 1))
if theWidth > theMaxWidth then
theRatio = int((theMaxWidth * 100) / theWidth)
theWidth = theMaxWidth
theHeight = int((theHeight * theRatio) / 100)
end if
if theHeight > theMaxHeight then
theRatio = int((theMaxHeight * 100) / theHeight)
theHeight = theMaxHeight
theWidth = int((theWidth * theRatio) / 100)
end if
end if
next
set path = nothing
set shell = nothing
end function
%>
<html>
<head>
<title>Gallery</title>
<style type="text/css">
.gallery {
float:left;
width: <%=maxWidth + 40%>;
height: <%=maxHeight + 40%>;
border: 1px solid #000000;
margin: 10;
text-align:center;
padding: 10px;
}
img {
border:none;
}
</style>
</head>
<body>
<%
set fso = server.createObject("Scripting.FileSystemObject")
if fso.folderExists(server.mapPath(imgPath)) then
set folder = fso.getFolder(server.mapPath(imgPath))
set files = folder.files
for each file in files
fileType = file.type
fileName = file.name
for t = 0 to uBound(imgTypes)
if fileType = imgTypes(t) then
call resizeImgView(imgPath, fileName, maxWidth, maxHeight, w, h)
%>
<div class="gallery">
[img]<%=imgPath & fileName%>[/img]" height="<%=h%>" alt="immagine <%=fileName%>" />
</div>
<%
exit for
end if
next
next
set files = nothing
set folder = nothing
end if
set fso = nothing
%>
</body>
</html>