User680026537 posted
Hey everyone. I am trying to create thumbnails of original images. So far I have this code...
Code:
<%@ Page Language="vb" Debug="true" %>
<%
' initialize objects
Dim strFilename as string
Dim g as System.Drawing.Image
Dim newWidth, newHeight, sizer
Dim boxWidth=100
Dim boxHeight=100
‘ set the filename
strFilename = Server.MapPath("./images/07005.jpg")
‘ create a new image from file
g = System.Drawing.Image.FromFile(strFilename)
If g.height > g.width Then ‘ portrait
sizer = boxWidth / g.height
Else
sizer = boxHeight / g.width
End If
newWidth=CInt(g.width * sizer)
newHeight=CInt(g.height * sizer)
dim g2 as New System.Drawing.Bitmap(g, newWidth, newHeight)
‘ set the content type
response.contenttype="image/jpeg"
‘ send the image to the viewer
g2.Save(Response.OutputStream, g.RawFormat)
‘ tidy up
g.dispose()
%>
How can I wrap this code in a loop to make thumbnails of the images in the images folder and save thumbnail jpg's in an images/thumb folder?
Thanks for the help!!