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 am using this shorthand. Sharing just in case someone needs a one-line solution.
$orientation = ( $width != $height ? ( $width > $height ? 'landscape' : 'portrait' ) : 'square' );
First it checks if image is not 1:1 (square). If it is not it determines the orientation (landscape / portrait).
I hope someone finds this helpful.