Sponsored Links

Go Back   WebMasters.org Forums > Website Design & Development > PHP Forum

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-06-2008, 01:10 PM
unleash unleash is offline
Junior Member
 
Join Date: Jul 2008
Posts: 11
Default Get the width and height of an image using a function in PHP

Overview
PHP provides a function to get the width and height of an image. The getimagesize() function will determine the size of image file including flash file(swf).

Syntax
PHP Code:
list($width$height$type$attr) = getimagesize("image_name.jpg"); 
Code
This is a sample code, change image_name to your image name and test it!

PHP Code:
<?php
                                                
                                                
list($width$height$type$attr) = getimagesize("image_name.jpg");                                                                                             echo "Image width " .$width;
                                                echo 
"<BR>";
                                                echo 
"Image height " .$height;
                                                echo 
"<BR>";
                                                echo 
"Image type " .$type;
                                                echo 
"<BR>";
                                                echo 
"Attribute " .$attr;
                                                
                                                
?>
When you run this script you will see the result like this

Image width 379
Image height 344
Image type 2
Image attribute width="379" height="344"

You will get the width, height, type of an image and also attribute of an image, I use this function in my image upload form.
Type of an image you can see from table below


Type of the image 1 = GIF 5 = PSD 9 = JPC 13 = SWC 2 = JPG 6 = BMP 10 = JP2 14 = IFF 3 = PNG 7 = TIFF(intel byte order) 11 = JPX 15 = WBMP 4 = SWF 8 = TIFF(motorola byte order) 12 = JB2 16 = XBM
__________________
imegashare.com | free image upload solution
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:20 PM.


Sponsored Links

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0
vB Ad Management by =RedTyger=