9951 explained code solutions for 126 technologies


php-gdHow to get image size (width & height)


<?php

$file = '/var/www/examples/heroine.png';
$size = getimagesize($file);

$width = $size[0];
$height = $size[1];ctrl + c
/var/www/examples/heroine.png

path to image to get size of

getimagesize

returns image size from given path

$width

will contain image width

$height

will contain image height


Usage example

<?php

$file = '/var/www/examples/heroine.png';
$size = getimagesize($file);

$width = $size[0];
$height = $size[1];

echo $width . 'x' . $height;
output
733x1100