tags:

views:

36

answers:

4

I was wondering how can I find the width of an image using php.

+2  A: 

getimagesize()

quantumSoup
+1  A: 

Use the GD libraries imagesx function, take a look at the manual page here.

Will A
+3  A: 

Easy, you can use getimagesize:

list($width, $height) = getimagesize($filename);
igorw
A: 

You can try with this code, you can see more in www.php.net

To a file:

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

To URL:

<?php
$size = getimagesize("http://www.example.com/gifs/logo.gif");
$size = getimagesize("http://www.example.com/gifs/lo%20go.gif");

?>

Only you have to give an output to variable.

Josh Ruiz