Php : How To Get Image Size From Directory Using Php

Php Code: How To Show Image Width And Height From A Folder Using Php

________________________________________________________


In this Php Tutorial we will Learn How  To Get And Display Images size ( width & height) From Folder Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "images/";

if(is_dir($dir_path))
{
    $files = scandir($dir_path);
    
    for($i = 0; $i < count($files); $i++)
    {
        if($files[$i] != '.' && $files[$i] != '..')
        {
            echo "File Name -> $files[$i]<br>";
            
            $imageSize = getimagesize("$dir_path$files[$i]");
            
            echo " -Image Width : $imageSize[0]<br>";

            echo " -Image Height : $imageSize[1]<br>";

            //jpg or png or gif .........
            echo " -Image Type : $imageSize[2]<br>";

            echo " -Image Width And Height: $imageSize[3]<br>";

            // display the images
            echo"<img src='$dir_path$files[$i]' style='width:100px;height:100px;'><br><br>";
        }
    }
}





                     
php display images width and height






Share this

Related Posts

Previous
Next Post »