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
Simple. Just check the width and height and compare them to get orientation. Then resize accordingly. Straight-forward really. If you are trying to maintain aspect ratio, but fit into some square box you could use something like this:
public static function fit_box($box = 200, $x = 100, $y = 100)
{
$scale = min($box / $x, $box / $y, 1);
return array(round($x * $scale, 0), round($y * $scale, 0));
}