ActiveX DLL to scale-resize an image (jpg or gif) from ASP.
Posted on 2003-11-21
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.PaintPicture Form1.Image1.Picture, 1, 1, iWidth, iHeight
SavePicture Form1.Picture1.Picture, sNewPath
I then call this from the ASP page:
========ASP Code (in the resizeimage.asp file)==========
Set objResize = Server.CreateObject("MyResize.ImageResizer")
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".
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,