SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Evangelist FCC's Avatar
    Join Date
    May 2006
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    SitePoint Wizard
    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.

  3. #3
    SitePoint Evangelist FCC's Avatar
    Join Date
    May 2006
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Enthusiast RaS!'s Avatar
    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

  5. #5
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In PHP you can use getimagesize().

  6. #6
    Are You There? KDesigns's Avatar
    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. 
    ChooseDaily.com - Follow on Twitter
    Top Resources for Web Designers and Developers Every Day!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •