php glob不读取垂直图像[关闭]

问题描述:

Would anybody know how to edit the following code to display the vertical images in the directory accurately? The default seems to be horizontal. Thanks very much.

<?php
$files = glob("images/*.*");
for ($i=0; $i<count($files); $i++)
{
$num = $files[$i];
echo '<img src="'.$num.'" alt="">'."<br>
<br>
<br>
";
}
?>

Even I didn't understand what you mean saying "vertical images", getting only images from a directory is more simple in your case;

$images = glob('/path_of_images/*.{jpeg,jpg,png,gif}', GLOB_BRACE);
foreach ($images as $image) {
    // so you can check the current image is image that you are looking for
    $image_data = exif_read_data($image);
    if ($image_data that im looking for)
        printf('<img src="path_of_images/%s" alt=""><br>', basename($image));
    // or check size
    $image_size = getimagesize($image);
    if ($image_size[0] > $image_size[1]) {
        // this is landscape???

See more details here: http://php.net/manual/en/function.exif-read-data.php