getimagesize in php – Get image width and height in PHP

Rate this post

getimagesize in php – The getimagesize() function in PHP is an inbuilt function which is used to get the size of an image. We can easily extract image information from the Image URL using PHP’s predefined function called getimagesize().

Free Live Chat for Any Issue

getimagesize in php

The getimagesize() function is used to display the size of an image. The getimagesize() function will determine the size of any given image file.

Syntax

list($width, $height, $type, $attr) = getimagesize("pakainfo_v1.jpg");

php getimagesize function – Get image information

Remote File Photos

<?php
$live_url = '../admin/themes/pakainfo.com/assets/img/pakainfo-logo.png';
$results = getimagesize($live_url);
print_r($results );
?>

Example

Array
(
    [0] => 400
    [1] => 150
    [2] => 3
    [3] => width="400" height="150"
    [bits] => 8
    [mime] => image/png
)

Don’t Miss : getimagesize in php

Read Also:  Delete Table Rows Using PHP JQuery Ajax

Get image width and height in PHP

code – getimagesize in php

<?php

list($width, $height, $type, $attr) = getimagesize("url/to/pakainfo_v1.jpg");

echo "Image width: " . $width;
echo "<br>";
echo "Image height: " . $height;
echo "<br>";
echo "Image type: " . $type;
echo "<br>";
echo "Attribute: " . $attr;

?>

PHP – getimagesize() Function

<?php
$image_info = getimagesize("pakainfo.png");
print_r($image_info);
?>

Results

Array ( [0] => 800 
        [1] => 230 
        [2] => 3 
        [3] => width="800" height="230" 
        [bits] => 8 
        [mime] => image/png )

getimagesize php

<?php
$size = getimagesize("https://www.pakainfo.com/admin/pakainfo_logo.gif");
$size = getimagesize("https://www.pakainfo.com/admin/pakainfo_logo.gif");

?>

getimagesize php

<?php
list($width, $height, $type, $attr) = getimagesize("img/pakainfo_logo.jpg");
echo "<img src=\"img/pakainfo_logo.jpg\" $attr alt=\"getimagesize()pakainfo\" />";
?>

For Type of image

Read Also:  Send WhatsAPP Message API using PHP Step By Step
1 = GIF 5 = PSD 9 = JPC 13 = SWC 2 = JPG 6 = BMP 10 = JP2 14 = IFF 3 = PNG 7 = TIFF(intel byte order) 11 = JPX 15 = WBMP 4 = SWF 8 = TIFF(motorola byte order) 12 = JB2 16 = XBM
Download

I hope you get an idea about getimagesize in php.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.