Saving resized Images

  • Thread starter Thread starter toma
  • Start date Start date
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>
 
Try something like this
yoursystemdrawingimage.save("rootpathfilename",ImageFormat.Jpeg)


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