Jump to content

Asp Image Size With Repeat


ibrahimjan

Recommended Posts

Hi All,I have been trying to make this piece of code to work for some time, I have a sub routine in a repeat loop, the loop gets images from a database, the sub routine retrieve the image dimensions (width x height) then I simply need to do "IMG_width/iWidth". But every time I run this code I get the following: Microsoft VBScript compilation error '800a03ea' Syntax error /svg1.asp, line 97 sub ImgDimension(img)^Thanks

Dim Repeat2__numRowsDim Repeat2__indexRepeat2__numRows = -1Repeat2__index = 0image_loop_numRows = image_loop_numRows + Repeat2__numRowsWhile ((Repeat2__numRows <> 0) AND (NOT image_loop.EOF)) dim iWidth, iheightdim myImg, fsdim IMG_width, IMG_height, Image_all, IMG_link, IMG_1MTX IMG_width=(image_loop.Fields.Item("Width").Value)IMG_height=(image_loop.Fields.Item("Height").Value)Image_all=(image_loop.Fields.Item("Image_all").Value)IMG_link= "/gallery/png_xph/"&Image_all&".png"  sub ImgDimension(img)Set fs= CreateObject("Scripting.FileSystemObject")if not fs.fileExists(img) then exit subset myImg = loadpicture(img)iWidth = round(myImg.width / 26.4583)iheight = round(myImg.height / 26.4583)set myImg = nothingend subImgDimension(Server.MapPath(IMG_link))  IMG_1MTX=IMG_width/iWidth     Repeat2__index=Repeat2__index+1  Repeat2__numRows=Repeat2__numRows-1  image_loop.MoveNext()Wend

Link to comment
Share on other sites

The code is not a function or a subroutine it is by it's self, also I have to keep ImgDimension inside the loop, as the value of IMG_link is dynamic and changes as it goes through the loop, to populate more than one image results, is there a way to make it work as it is inside the loop, can we change the code, instead of using subroutines?? to get the image dimensions.

Link to comment
Share on other sites

I tried it this way, please have a look, but I have just found out that I cant use "loadpicture" on .png, it does not support it?? any other ideas how I can get the width and height of a .png file?? the code is inside the loop

dim iWidth, iheightdim myImg, fsdim IMG_width, IMG_height, Image_all, IMG_link, IMG_1MTX IMG_width=(image_loop.Fields.Item("Width").Value)IMG_height=(image_loop.Fields.Item("Height").Value)Image_all=(image_loop.Fields.Item("Image_all").Value)IMG_link= "/gallery/png_xph/"&Image_all&".png"img= (Server.MapPath(IMG_link)) set myImg = loadpicture(img)iWidth = round(myImg.width / 26.4583)iheight = round(myImg.height / 26.4583)set myImg = nothing response.Write(iWidth&"x"&iheight)&"<p>"

Link to comment
Share on other sites

I figured out a different approach to this issue, I managed to find a small converter to run on the server, my idea is to convert the .png to .jpg to a temp location, read the width and the height, then delete the file. This is what I got so far for converting the file:

dim CSet C=CreateObject("ImageConverter.ImageConverterX") 'this is line 10C.Convert "c:\veg.PNG", "c:\veg2.JPG", "-cJPG"Response.Write C.ErrorMessageset C = nothing

The problem I am facing is that I have installed the ImageConverter.dll in the registry, but every time I run the above script I get the following error: Microsoft VBScript runtime error '800a0046' Permission denied: 'CreateObject' /test.asp, line 10 Any ideas to why this is happening??

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...