SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Code to grab Image Dimensions
-
Aug 1, 2006, 01:00 #1
Code to grab Image Dimensions
Hi all,
Is there any code from any language which grabs the image dimensions of a .gif, .jpeg or any type of image file?
Thanks.
-
Aug 1, 2006, 01:22 #2
- Join Date
- Jul 2003
- Location
- Kent
- Posts
- 1,921
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
grab from where?
an image on a web page
the size the image as displayed on the web page (as opposed to its true size)
the size of the image stored on your hard disk?
all image manipulation software will dispaly this for an image on your PC, and right clicking in a browser will display the current on-screen size. As will viewing the actual html.Dr John
www.kidneydialysis.org.uk
-
Aug 1, 2006, 01:43 #3
An image from a webpage I guess.
Basically, I have a CMS which allows people to change images. And before they change the old picture I want to display it allow with the dimensions of it to give them an ideal of what an ideal size would be.
-
Aug 1, 2006, 02:08 #4
- Join Date
- Mar 2004
- Location
- Italy
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Except the classic ASP, all languages have built-in functions (or by using right extensions) to retrieve the dimension of an image, even with javascript you can do it.
This message was written using 100% recycled electrons
-
Aug 1, 2006, 05:07 #5
- Join Date
- May 2003
- Location
- Cambridge, UK
- Posts
- 2,366
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
In PHP you can use getimagesize().
-
Aug 1, 2006, 09:48 #6
- Join Date
- Oct 2003
- Location
- Your Monitor
- Posts
- 1,146
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If using PHP, as Buddy said above...
PHP Code:$image = getimagesize('image.jpg');
$width = $image[0];
$height = $image[1];
$type_of_image = $image[2];
$text_string_for_tag = $image[3];
//text string will have the correct height="yyy" and width="xxx" string that can be used directly in an <img/> tag.
Bookmarks