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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting pixel dimension of a jpg

Status
Not open for further replies.

Bignewbie

Programmer
Joined
Feb 22, 2001
Messages
351
Location
PH
hey ppl!


could anyone tell me how to detect the actual pixel dimensions of a jpeg image? not the byte size, the pixel dimensions ?

thanks



bignewbie
 
The way I do it is if the image is defined as an Image object in Javascript, you can just use the height & width properties.
Code:
var myImg=new Image();
myImg.src="images/myimage.jpg";
// this line waits for the image to finish loading so we
// can get the height & width properties
while (!myImg.complete) {}

var iWidth=myImg.width;
var iHeight=myImg.height;

This works for me on IE. I'm no expert so there may be simpler ways.

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top