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

Check picture size

Status
Not open for further replies.

Smarty

Programmer
Apr 12, 2001
191
BE
Is there a possibility to check wether a picture will be portrait or landscape? It would be a lot easier for my picture gallery...

Anyone who did this before?
 
Try to use the
Code:
"clientHeight"
and
Code:
"clientWidth"
property of your <IMG> object Water is not bad as soon as it stays out human body ;-)
 
exemple in JScript :
Code:
<html>
	<head>
		<title>Untitled</title>
	</head>
	<Script language=&quot;Javascript&quot;>
var isIE4;
var isNS4;

function getRef(id)
{
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}

function initPage()
{

//- Détection du browser -//
isIE4 = ((document.all ) ? true : false);
isNS4 = (document.layers ? true : false);
var width = getRef(&quot;toto&quot;).width;
var height=getRef(&quot;toto&quot;).height;

if (width > height) alert(&quot;landscape&quot;);
else alert(&quot;portrait&quot;);

return true;
}

</Script>
	<BODY onload=&quot;initPage();&quot;>
		<img id=&quot;toto&quot; src=&quot;valeur.jpg&quot; border=&quot;0&quot;>
	</BODY>
</html>
Water is not bad as soon as it stays out human body ;-)
 
This is not what I want I guess... I want it in my ASP so that I can adjust the output code in my ASP page...
 
Well, I didn't understand that. I don't know how you can deal with that except if you write a kind of parameter file to this format :
Code:
toto.gif|L
tutu.gif|P
anotherone.jpg|L
[code]
Then you open this file in ASP and read it to determine if your picture is portrait (2nd param to P) or landscape (2nd param to L) Water is not bad as soon as it stays out human body ;-)
 
Smarty, I have a photo Gallery and keep the scans one of 2 sizes, depending on whether they are Portrait or Landscape. This makes life a lot easier than trying to fit all different sizes together!! The alternative used by a lot of people is to put the pictures in a standard size square box, which I think can look messy. Doing it my way, I then send a variable with the pictures e.g. when they are clicked on, which is either 1 if landscape or 2 if portrait.

This will be a lot neater than varying the size of the pictures.
 
basil3legs,

This is also how I want to do this, I only have 2 fixed formats, but for the pop-up window, I need to know if a picture is landscape or portrait, because the call for the pop-up window will be different in heigth and width
 
So why not to use my exemple replacing the alerts by some &quot;window.open&quot; ? Water is not bad as soon as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top