Retrieve image orientation in PHP

image, orientation, php

Solution

I've always done this:

list($width, $height) = getimagesize('image.jpg');
if ($width > $height) {
    // Landscape
} else {
    // Portrait or Square
}

Problem

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 down to a smaller size, I want to know how the image is orientated in order to scale it properly. Thanks for your answer!

Original source