PDA

View Full Version : How can I know the size of an image using ASP?


jcjimc
10-15-2002, 06:37 PM
Hello group,

I have a database with the names of some images that are located in the server and the web works fine.

What I want to know is the size of each image using ASP to make a window.open with that information.

How can I do it?

Thanks in advance

Roy Sinclair
10-15-2002, 09:21 PM
Right now? From ASP? You would have to use the File System Object to open the image file, read the header and depending on the type of image file decode the header to determine the image size.

Of course you could also just send the image to the window and let a little javascript on the page pick off that information instead.

whammy
10-16-2002, 12:11 AM
If you're using window.open (which is javascript and can't be anything else), then I'd use javascript to determine the size of the picture anyway. ;)

jcjimc
10-16-2002, 07:54 PM
Thank you very much to both.

The real thing is that I don't mind to do it with JS or ASP, I thought that it was better with ASP and that's why I asked it here, in the ASP forum.

By the way, I don't know how to do it with JS, I know that this is a question that I must do in the JavaScript forum but, Can you help me with the JavaScript code to know the size of an image?

Thanks

whammy
10-19-2002, 03:09 AM
Since noone has posted a reply, and I haven't had time to mess with a solution for you in javascript, I'm going to move this post to the javascript programming forum as it seems most appropriate.

:)

adios
10-19-2002, 03:35 AM
You'd need to preload the image - this doesn't display it - and, when it's on board (Image.onload handler runs), get the Image.width & Image.height properties (.offsetWidth/Height in newer browsers works as well).

whammy
10-19-2002, 03:40 AM
Ahh yes, preloading the image is the solution. For more info see some scripts at:

http://www.javascriptkit.com

That should give you a good solid foundation for what adios is referring to. :)

adios
10-19-2002, 03:54 AM
http://www.faqts.com/knowledge_base/view.phtml/aid/2090/fid/122
http://www.faqts.com/knowledge_base/index.phtml/fid/122
:cool:

whammy
10-19-2002, 04:06 AM
Geez, that second link is fairly exhaustive. ;)