Reputation: 1287
How can I recognize if image stored in same folder as PHP script is landscape or portrait ? I need to implement it to this function:
if ($dir = @opendir($folder))
{
while ($file = readdir($dir))
{
if (in_array(strtolower(FileExt($file)), $extensions))
{
if (!is_dir($file))
{
if (isLandsape($file))
{
$files[] = $file;
}
}
}
}
closedir($dir);
}
Upvotes: 1
Views: 3814
Reputation: 165
A function like this :
function isLandsape($file)
{
list($width, $height) = getimagesize($file);
return $width > $height;
}
Upvotes: 4
Reputation: 2017
list($width, $height) = getimagesize($file);
if ($width > $height) {
$orientation = "Landscape"; }
else {
$orientation = "Portrait"; }
Upvotes: 3