Forum Moderators: open

Message Too Old, No Replies

Determining image width and height

Using classic asp

         

bateman_ap

12:29 pm on Feb 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, I am trying to write a app to add images to a database with titles etc. However there is one bit that is puzzling me. I can upload my files to the server etc using a form but what i want to do is create 2 values, x and y that contain the height and width of a recently uploaded image.

ie. I can upload 1.jpg to my server, this now sits at www.domain.com/images/1.jpg
Now I can display this on the page using <img src="/images/1.jpg" />

What I would like to do is create 2 variables that have the height and width in pixels, ie
<%
xwidth = 200
yheight = 200
%>

But i just can't work out how to get the image specs.

Easy_Coder

1:49 pm on Feb 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know if you can accomplish that in ASP. I've seen it done in vb com with the StdPicture Object.

bateman_ap

6:39 pm on Feb 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In case anyone was wondering I finally solved it

Using the following function I could determine the width and height

dim iWidth, iHeight
sub ImgDimension(img)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
if not fs.fileExists(img) then exit sub
set myImg = loadpicture(img)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
set myImg = nothing
end sub

then if i put the image path into

ImgDimension(Server.MapPath("/images/image.jpg"))

You can use iWidth and iHeight to get the width and height

dotme

7:50 pm on Feb 21, 2005 (gmt 0)

10+ Year Member



Well, that's just slick! I didn't know this could be done. Nice job.

Easy_Coder

1:58 pm on Feb 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That is slick... awesome.