Forum Moderators: open

Message Too Old, No Replies

How to extract width & height from images in folder?

         

may_hem1

11:41 am on Sep 5, 2003 (gmt 0)

10+ Year Member



Hi, how can ASP automatically find out the width & height of an image?

I want to create a Web page which automatically shows images from a folder and I want it to have a fixed size for the <IMG> tags, as well as listing the width & height below each image.

Does it make any difference if I have both JPEG and GIF images?

Any guidance would be appreciated.

Thx,
May

mattglet

5:06 pm on Sep 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i don't think there's a way to do that, but i may be wrong. maybe someone else knows for sure.

-Matt

aspdesigner

8:54 pm on Sep 6, 2003 (gmt 0)

10+ Year Member



You could do it, but you would need to examine the header in the graphic file itself and extract the size information. JPG or GIF would matter, as the file formats are different. The problem is you would likely need a component to access the binary file data. If you have to write a component, it would probably be easier to just include the JPG/GIF size extract code in it as well.

I believe there are also commercial graphics components available that will also do this for you.

If you don't want to deal with components, you might also think about using client-side Javascript, this won't get you fixed-size IMG tags, but you might try pulling the sizes from the browser and display them under the photos.

davemarks

11:45 am on Sep 7, 2003 (gmt 0)

10+ Year Member



ASPJpeg from Persits allows you to do just this, and it supports all the major image formats...

aspdaddy

1:00 pm on Sep 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



AFAIK, theres no way to do this using the FSO and asp, you only have access to the files name, type,size, path etc.

It would be extra work , but you could name the images specially and then parse the values e.g

myImage1_100_120.jpg

>examine the header in the graphic file itself >and extract the size information

Can you give us an example then?

aspdesigner

2:03 pm on Sep 8, 2003 (gmt 0)

10+ Year Member



I believe I indicated that you would end up having to write a component. You wouldn't be limited to FSO in that case.

>>examine the header in the graphic file itself >and extract the size information
>
>Can you give us an example then?

Sample code in a wide variety of languages for extracting size information from graphics files is quite easy to find with a little searching. The standard web graphic file formats are also well-documented. I can provide links if you're interested.

Zaphod Beeblebrox

11:50 am on Sep 12, 2003 (gmt 0)

10+ Year Member



Try this one, I use it too: [4guysfromrolla.com...]