James
James

Reputation: 43647

PHP image dimension

How to get width and height of an image?

I have $variable = 'http://site.com/image.png"

Want to get width of this image to $width and height to $height.

Like: $variable = 'http://site.com/image.png"

$width = '300'; // image width is 300px
$height = '500'; // height is 500px

Thanks.

Upvotes: 0

Views: 3476

Answers (2)

Alex Pliutau
Alex Pliutau

Reputation: 21957

$variable = 'http://site.com/image.png';
$image    = getimagesize($variable);
$width    = $image[0];
$height   = $image[1];
$type     = $image[2];

Upvotes: 2

Karasutengu
Karasutengu

Reputation: 301

getimagesize function. Maybe it will help you.

Upvotes: 1

Related Questions