PDA

View Full Version : Problem with Persits component for resizing image using asp



SBUH
September 17th, 2003, 12:52 PM
Hello, I have persits component on the server for resizing the image and resave it as ch_imagename in the save folder as the original image uploaded by the user from their local disc. But the page keeps on giving error message. I have no idea whether it is because I didn't register the component in the right way or I didn't write my code in the write way.

Could any one who have some experience with those things give me a hand on it? Thanks very much in advance!



<%
.....

File.SaveToDisk "C:\Inetpub\wwwroot\myweb\uploadedimage"
Response.write(session("newFileName")) ----this is for saving
' the original image and send the name to session variable

dim Jpeg,Path
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath("../uploadedimage/") & session("newFileName")

Jpeg.Open Path --here is error saying
-----Persits.Jpeg.1 (0x800A0002) Access is denied.

width=jpeg.originalwidth
height=jpeg.originalheight
if width>=height then
forma="H"
else
forma="V"
end if

if forma="H" then
height2=(100*height)/width
Jpeg.Width = 100
Jpeg.Height = height2
else
width2=(100*width)/height
jpeg.width=width2
jpeg.height=100
end if

CARACTERISTICAS
Jpeg.Sharpen 1, 130
Jpeg.Interpolation = 2 'Bicubic

create thumbnail and save it to disk
jpeg.Save Server.MapPath("C:\Inetpub\wwwroot\myweb\uploadedimage") & "\ch_" & session("newFileName")

abzoid
September 17th, 2003, 01:42 PM
Insert write statement to display the Path, just before Jpeg.Open, so you can verify that the path is correct.

SBUH
September 18th, 2003, 05:20 AM
when I do that, it shows like
c:\inetpub\wwwroot\myweb\uploadedimage

It seems it is right
by the way, should the path including the name also, since it is like Path = Server.MapPath("../uploadedimage/") & session("newFileName").

I am new to this component and hope u could help me to find the solution. Thanks very much in advance!

abzoid
September 18th, 2003, 07:07 AM
yes, the path should also include the file name, otherwise how will it know what file to open. I think you need to add another set of parenthesis, like this.

Path = Server.MapPath (("../uploadedimage/") & session("newFileName"))

SBUH
September 18th, 2003, 08:54 AM
thanks very much and it works now. BR

abzoid
September 18th, 2003, 09:00 AM
You're welcome. :}

The print statement is still a programmer's most powerful debug tool. :thumb: