dtukyb8095 2013-01-24 22:48
浏览 7
已采纳

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>
";
}
?>
  • 写回答

1条回答 默认 最新

  • duan1982453 2013-01-24 23:34
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)