James_Andrews
asked on
ActiveX DLL to scale-resize an image (jpg or gif) from ASP.
Hi,
I am trying to build an ActiveX Dll for use from ASP, to resize a specified image to the required size. The image resize must be to scale and the program must support JPG, GIF and BMP.
I have some code (in VB6) which I have started with (not sure if this will only work for bitmaps - if at all).
=============Code in VB6 (the dll file) ====================
Public Sub ResizeImage(sImgPath, sNewPath, iWidth, iHeight)
Form1.Image1.Picture = LoadPicture(sImgPath)
Set Picture1.Picture = Image1.Picture
Form1.Picture1.AutoRedraw = 1
Form1.Picture1.PaintPictur e Form1.Image1.Picture, 1, 1, iWidth, iHeight
SavePicture Form1.Picture1.Picture, sNewPath
End Sub
I then call this from the ASP page:
========ASP Code (in the resizeimage.asp file)==========
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim objResize
Set objResize = Server.CreateObject("MyRes ize.ImageR esizer")
MyResize.ResizeImage "C:\Site\htDocs\Futurama.b mp","C:\Si te\htDocs\ Futurama_s m.bmp",80, 60
Set MyResize=Nothing
%>
NB: This is example code and intentionally uses literals.
The ASP page returns "Object Required" on line 6 (MyResize.ResizeImage) - but does seem to execute past the Form1.Image1.Picture = LoadPicture(sImgPath) line because if you pass an invalid filename to MyResize.ResizeImage then the ASP error returns "File not found".
P.S
The DLL file is correctly registered and I cannot see any permissions problems (either to the DLL file or the Image Files).
Please advise if this method is innappropriate for my requirements.
Thank you for your time,
James.
I am trying to build an ActiveX Dll for use from ASP, to resize a specified image to the required size. The image resize must be to scale and the program must support JPG, GIF and BMP.
I have some code (in VB6) which I have started with (not sure if this will only work for bitmaps - if at all).
=============Code in VB6 (the dll file) ====================
Public Sub ResizeImage(sImgPath, sNewPath, iWidth, iHeight)
Form1.Image1.Picture = LoadPicture(sImgPath)
Set Picture1.Picture = Image1.Picture
Form1.Picture1.AutoRedraw = 1
Form1.Picture1.PaintPictur
SavePicture Form1.Picture1.Picture, sNewPath
End Sub
I then call this from the ASP page:
========ASP Code (in the resizeimage.asp file)==========
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim objResize
Set objResize = Server.CreateObject("MyRes
MyResize.ResizeImage "C:\Site\htDocs\Futurama.b
Set MyResize=Nothing
%>
NB: This is example code and intentionally uses literals.
The ASP page returns "Object Required" on line 6 (MyResize.ResizeImage) - but does seem to execute past the Form1.Image1.Picture = LoadPicture(sImgPath) line because if you pass an invalid filename to MyResize.ResizeImage then the ASP error returns "File not found".
P.S
The DLL file is correctly registered and I cannot see any permissions problems (either to the DLL file or the Image Files).
Please advise if this method is innappropriate for my requirements.
Thank you for your time,
James.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:))
, azra is right!
, azra is right!
ASKER
Yes, sorry, that is a typo.
Azra,
I am trying to debug the DLL, but the only error I get is the error from the ASP page, which is object required (the other code does not have that typo).
Azra,
I am trying to debug the DLL, but the only error I get is the error from the ASP page, which is object required (the other code does not have that typo).
How far into the code of the DLL do you get when debugging before the error occurs?
ASKER
From above:
The ASP page returns "Object Required" on line 6 (MyResize.ResizeImage) - but does seem to execute past the Form1.Image1.Picture = LoadPicture(sImgPath) line because if you pass an invalid filename to MyResize.ResizeImage then the ASP error returns "File not found".
The ASP page returns "Object Required" on line 6 (MyResize.ResizeImage) - but does seem to execute past the Form1.Image1.Picture = LoadPicture(sImgPath) line because if you pass an invalid filename to MyResize.ResizeImage then the ASP error returns "File not found".
Is the picture saved to the file? I assume Set MyResize = Nothing is a typo as well?
What I meant be debugging was, go to Project -> Properties in your DLL project, select the Debugging tab, ensure "wait for components to be created" option is selected. Press F5 to put your project in "run" mode with a breakpoint set on the first line in your ResizeImage sub routine. Then open your ASP page that calls this dll and it should jump into your DLL project allowing you to step through the code.
What I meant be debugging was, go to Project -> Properties in your DLL project, select the Debugging tab, ensure "wait for components to be created" option is selected. Press F5 to put your project in "run" mode with a breakpoint set on the first line in your ResizeImage sub routine. Then open your ASP page that calls this dll and it should jump into your DLL project allowing you to step through the code.
ASKER
Yes, thats's a typo as well. I renamed it MyResize in the code to make it obvious that it was my component - must have missed those two.
OK - Thanks very much - I didn't know you could do that.
OK - Thanks very much - I didn't know you could do that.
ASKER
The resizing of the image is not for display. I want to take load an image file, "Dog_Big.jpg", and create a scaled down version of it "Dog_Small.jpg".
Sorry if this wasn't clear.