Forum Moderators: open

Message Too Old, No Replies

working with AspImage

resizing an image with AspImage

         

sentiblue

10:08 pm on Mar 5, 2004 (gmt 0)



Hi all.... I'm a new guy here... just found this site from google.... hope to find a tip from you guys...

I'm doing a page that allows users to upload couple pictures to their report and have it resize to a standard requirement of max 450pixels wide.

I use AspSmartUpload to upload the photos... save them to a temp folder... now the step that I got stuck is loading those pictures into aspImage object and resize them...

I followed instructions from serverobjects.com but I seem to have a division by zero error. Please see below for my code. If anyone has a sample of similar work... I'd most certainly appreciate it if you can share the code.


<%
'This sub is used to resize the photo
Sub ResizeX (intXSize)
Dim intYSize
intYSize = (intXSize / myImage.MaxX) * myImage.MaxY
myImage.ResizeR intXSize, intYSize
End Sub

' Creating the upload object
Dim MyUpLoad
Set MyUpload = Server.CreateObject("AspSmartUpLoad.SmartUpLoad")

' Creating the Image object
Dim myImage
Set myImage = Server.CreateObject("AspImage.Image")

' Accept the upload and save in temp
MyUpload.Upload
Dim strFilename
i=1
For each File in MyUpload.Files
File.SaveAs("temp/" & File.Filename)

' Loading Image object and resize
myImage.LoadImage("temp/" & File.Filename)
Call ResizeX(450)

' Save Photo File
myImage.Filename=Request.ServerVariables("APPL_PHYSICAL_PATH") & "\photos\" & Request.QueryString("OrderID") & ".jpg"
myImage.SaveImage
%>
<TR>
<TD align="center" valign="middle"><%=imagepath%><BR><IMG BORDER="1" SRC="temp/<%=Request.QueryString("OrderID")%>-<%=i%>.jpg"></TD>
</TR>
<%
i = i + 1
Next
Set myImage=Nothing
Set MyUpload=Nothing
%>

mattglet

9:32 pm on Mar 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you uploading .jpg files, or .gif files?

-Matt