Saving resized Images

T

toma

Hi!
I found out how to manipulate (read,resize, etc..) images using
System.Drawin namespace from this site:
http://authors.aspalliance.com/chrisg/default.asp?category=9
But i don't know how to save resize image on hard disc. So i hope someon
could help me.
The biggest problem is that i run win98 system so no .Net framework testing
is possible.

If someone could give me a hint on how to change this asp code to actualy
save resized image on disk, it would be great!

'INCLUDES
<%@ 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

'******************************************
'* HERE i need something (some class or function)
'* that will be placed instead of Response.OutputStream
'* ..something like a file object or something. if anyone knows
'* what to put here it would be great
''*********************************************

' send the resized image to the viewer
imgOutput.save(response.outputstream, thisformat) ' output to the user

' tidy up
g.dispose()
imgOutput.dispose()

end sub

' 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>
 
V

vMike

Try something like this
yoursystemdrawingimage.save("rootpathfilename",ImageFormat.Jpeg)


you might need to replace the ImageFormat.Jpeg to another format for your
particular image.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,985
Messages
2,570,199
Members
46,766
Latest member
rignpype

Latest Threads

Top