Page 1 of 1

image width and height

Posted: Wed Sep 20, 2006 2:51 pm
by speedy33417
I have the following code to display some thumb pictures

Code: Select all

echo "<img border=\"0\" src=\"http://www.mysite.com/album/pics/" . $result['picture_filename'][$currentpic] . "-thumb.jpg\" width=\"150\" height=\"113\"><br>" . "\n";
I use mostly 640x480 pictures with 150x113 thumb pictures. Key word being mostly. I just realized that my pictures could be portrait or landscape or in rare cases the proportion could be different. I'd hate to do it without width and height values, because until the picture is totally downloaded the browser doesn't keep the required space open for it, shifting the set up of my page until all the thumbs are done downloading.

How do I get these values for a picture?

Thanks.

Posted: Wed Sep 20, 2006 2:53 pm
by volka
http://de2.php.net/image
getimagesize -- Get the size of an image

Posted: Wed Sep 20, 2006 3:09 pm
by speedy33417
Does that mean that there is no php code to do it without an open source application?

Posted: Wed Sep 20, 2006 3:11 pm
by volka
:?:
a) php itself is open source, so the answer must be "No?" ;)
b)
http://de2.php.net/getimagesize wrote:Note: The getimagesize() function does not require the GD image library.

Posted: Wed Sep 20, 2006 3:11 pm
by SpecialK
The GD library is for use with PHP. I would call it more of an extension then another application.

I could have used it a few times already, but my manager didnt want to use it which restricted what could be done.

Posted: Wed Sep 20, 2006 5:42 pm
by onion2k
SpecialK wrote:I could have used it a few times already, but my manager didnt want to use it which restricted what could be done.
Why on Earth is your manager making development decisions? Everyone should use GD whereever it's applicable. Coz it's ace. I am not biased at all. ;)

Posted: Wed Sep 20, 2006 9:48 pm
by n00b Saibot
if your manager is biased try ImageMagick instead and use it to grow horns on your manager :lol:

Posted: Thu Sep 21, 2006 7:42 am
by speedy33417
For those of you who's looking for a code to get the size of an image this is what I ended up with:

Code: Select all

$size = getimagesize("images/pic.jpg");
$width = $size[0];
$height = $size[1];

Posted: Thu Sep 21, 2006 8:01 am
by onion2k
That $size array is superfluous.

Code: Select all

list($width,$height) = getimagesize("images/pic.jpg");
Does the same thing.