PDA

View Full Version : ASPImage Saving Problem (not a faq)


skoeld
08-25-2004, 01:15 AM
I've written a little resizing script, which doesn't produce any errors, however the new file is not saved.
Funny enough, if I save the file under the same name and then load it in another page again, the .MaxX property does give me the new dimension, the picture itself looks the same though (despite me having emptied the browser cache completely and also having downloaded the file via ftp and double checked it).
If I rename the file before saving it, I still don't get an error message, put the file is not generated.

Here is my asp script:

'#################################################
filename =Trim(Request.Form("resizefile2"))
path="upload"
Xmax = 100
Ymax = 100

Set objImage = Server.CreateObject("AspImage.Image")
objImage.ImageFormat = 1
objImage.PixelFormat = 6

if objImage.LoadImage("/"&path&"/"&filename) then
Response.Write("Loading succesfull![b]")
Response.Write("original X: "&objImage.MaxX &"original Y: "&objImage.MaxY&"[b]")

'calculate new dimension
'----------------------------
tempx = int(objImage.MaxX)
tempy = int(objImage.MaxY)
if (tempx=> tempy ) then
ratio = Xmax/tempx
else
ratio = Ymax/tempy
end if
Response.Write("tempX: "&tempx &" tempy: "&tempy&"[b]")

tempx = int(tempx*ratio)
tempy = int(tempy*ratio)
'----------------------------

' resample picture
'----------------------------
objImage.ResizeR tempx,tempy
Response.Write("new X: "&tempx &"new y: "&tempy&"[b]")
'----------------------------

' save picture
'----------------------------
filename="thumb_"&filename
objImage.Filename = "/"&path&"/"&filename
Response.Write(objImage.Filename&"[b]")
if objImage.SaveImage then
Response.Write("Saving succesfull![b]")
set objImage = nothing
else
Response.Write("Saving failed: "&objImage.Error&"[b]")
end if
'----------------------------

else
'loading error
'----------------------------
Response.Write("Loading failed: "&objImage.Error&"[b]")
set objImage = nothing
'----------------------------
end if


' load picture into page
'----------------------------
Response.Write("<img name='' src='"&path&"/"&filename&" alt=''>
")
'################################################

Aristotle
08-25-2004, 01:48 AM
I think you need to use the physical path, as in e:\whatever\directory\pic.jpg