How can I get the image orientation (landscape or portrait) of an image (JPEG or PNG) in PHP?
I created a php site where users can upload pictures. Before I scale them
I use a generalized scaling down algorithm like . ..
function calculateSize($width, $height){
if($width <= maxSize && $height <= maxSize){
$ratio = 1;
} else if ($width > maxSize){
$ratio = maxSize/$width;
} else{
$ratio = maxSize/$height;
}
$thumbwidth = ($width * $ratio);
$thumbheight = ($height * $ratio);
}
Here max size is the one I initialized to something like 120px for both height and width . . . so that the thumbnail does not exceed that size . . ..
This Works for me which is irrespective of landscape or portrait orientation and can be applied generally