To get the width and height of the image use getimagesize(path_name), this function returns the array which contains the height, width, image_type constant and other image related info. By the following code you can achive that.
list($width, $height) = getimagesize("file path");
if ($width > $height)
{
	//landscape	
}
else
{
	// Portrait
}
See also PHP resize image using ratio
What do you think?