Page 1 of 1
retrieve image size to add it to the page
Posted: Sun Aug 16, 2009 5:48 am
by aneuryzma
Hi,
I have the following image url:
Code: Select all
$imageURL = $_images_dir_.'/'.$images[$a]['filename'];
I need to know if the image from filesystem is a portrait or a landscape before to add it to the page with the right size.
How can I do it ?
thanks
Re: retrieve image size to add it to the page
Posted: Sun Aug 16, 2009 6:02 am
by webmonkey88
just done a quick google and found the function : getimagesize()
http://uk2.php.net/function.getimagesize
then once you have the height and width you should be ok.
Re: retrieve image size to add it to the page
Posted: Sun Aug 16, 2009 8:54 am
by aneuryzma
Hi,
thanks... I did it, but I don't get why my variables are empty... the url of the image is correct, I checked 3 times: it is relative to php file location.
Code: Select all
list($width1, $height1) = getimagesize('../../images/stories/'.$_images_dir_.'/'.$images[$a]['filename']);
echo $width1; //gives nothing
thanks
Re: retrieve image size to add it to the page
Posted: Thu Sep 03, 2009 4:07 am
by aneuryzma
hi,
is maybe a permission problem ?
when I print $width1, it is completely empty...
thanks
Re: retrieve image size to add it to the page
Posted: Thu Sep 03, 2009 6:03 am
by aneuryzma
it was the wrong path (absolute /relative)
solved thanks