The camera detects the phone's orientation and stores it as metadata. So the height and width will always be the same, and the orientation when displayed in Zune, Picture Viewer, or most other programs will be read out of the metadata.
Here is a resource explaining it and providing sample code in C#. The particularly important part is right at the bottom. To use this, you will need this library (also a useful guide there):
void OnCameraCaptureCompleted(object sender, PhotoResult e)
{
// figure out the orientation from EXIF data
e.ChosenPhoto.Position = 0;
JpegInfo info = ExifReader.ReadJpeg(e.ChosenPhoto, e.OriginalFileName);
_width = info.Width;
_height = info.Height;
_orientation = info.Orientation;
PostedUri.Text = info.Orientation.ToString();
switch (info.Orientation)
{
case ExifOrientation.TopLeft:
case ExifOrientation.Undefined:
_angle = 0;
break;
case ExifOrientation.TopRight:
_angle = 90;
break;
case ExifOrientation.BottomRight:
_angle = 180;
break;
case ExifOrientation.BottomLeft:
_angle = 270;
break;
}
.....
}