Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get image height and with knowing the URL???

Status
Not open for further replies.

serezhka

Programmer
Sep 20, 2010
3
CA
Good day all...
I am looking for the way i can get image height and width...
image is placed on the server: http:/Knowing this path to the image... i need to know its width and height... is there a way i can do it with javascript???

Thank you very much.
Sergey
 
Well, I don't think it's possible.
Someone else might know though!
//Daniel :(
 
function ShowDimensions(mypage)
{
var imgTest=new Image();

imgTest.src=mypage;

var imgHeight = imgTest.height;
var imgWidth = imgTest.width;
}


The problem that I have had is that it takes a while for imgHeight and imgWidth to be populated, unless you preload the image .
Kathryn


 
Try creating an image object, setting it's source to that url, and then checking the width and height of the image object:
Code:
var theImage = new Image();
theImage.src = "http:/[URL unfurl="true"]www.something.com/images/1.gif";[/URL]
var width = theImage.width;
var height = theImage.height;
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thank you very much!!!
I found the solution and it looks like this one example:

var width = theImage.width;
var height = theImage.height;

Thank you very much......
Sergey


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top