Request for Question Clarification by
googleexpert-ga
on
29 Oct 2004 07:59 PDT
Hi valadares-ga,
I found a script using ASP.NET code. Will the following be of use to you?
<%@ Page Language="vb" Debug="True" %>
<%@ import namespace="System" %>
<%@ import namespace="System.Drawing" %>
<%@ import namespace="System.Drawing.Imaging" %>
<%@ import namespace="System.IO" %>
<script runat="server">
Sub sendFile()
' create New image and bitmap objects. Load the image file and put
into a resized bitmap.
dim g as System.Drawing.Image =
System.Drawing.Image.FromFile(server.mappath(request("src")))
dim thisFormat = g.rawformat
dim imgOutput as New Bitmap(g, cint(request("width")), cint(request("height")))
' Set the contenttype
if thisformat.equals(system.drawing.imaging.imageformat.Gif) then
response.contenttype="image/gif"
else
response.contenttype="image/jpeg"
end if
' send the resized image to the viewer
imgOutput.save(response.outputstream, thisformat) ' output to the user
' tidy up
g.dispose()
imgOutput.dispose()
end sub
Sub sendError()
' if no height, width, src then output "error"
dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb)
dim g as graphics = graphics.fromimage(imgOutput) ' create a New
graphic object from the above bmp
g.clear(color.yellow) ' blank the image
g.drawString("ERROR!", New
font("verdana",14,fontstyle.bold),systembrushes.windowtext, New
pointF(2,2))
' Set the contenttype
response.contenttype="image/gif"
' send the resized image to the viewer
imgOutput.save(response.outputstream, imageformat.gif) ' output to the user
' tidy up
g.dispose()
imgOutput.dispose()
end sub
</script>
<%
' make sure Nothing has gone to the client
response.clear
if request("src")="" or request("height")="" or request("width")="" then
call sendError()
else
if file.exists(server.mappath(request("src"))) then
call sendFile()
else
call sendError()
end if
end if
response.end
%>
[Source: http://www.plus.hr/skripte/asp.net/resize_image.html]
Thank you.
-googleexpert