Sometimes there can be a requirement to get an images' width and height, may be to re-size them accordingly or whatever, you can use the getimagesize function of php, you can pass the URL of the image (If the image is not in your site) or you can give the relative path (if you want to get the sizes of an image of your site), here how
By URL
list($width, $height, $type, $attr) = getimagesize(http://www.blogger.com/img/blogger-logo-small.png");
$image_width = $width;
$image_height = $height;
By Relative Path
list($width, $height, $type, $attr) = getimagesize(img/blogger-logo-small.png");
$image_width = $width;
$image_height = $height;
No comments:
Post a Comment