How to check for image Dimensions

Discussion in 'PHP' started by Phil Vessey, Jan 23, 2007.

  1. #1
    Hi

    Im looking for a way to check what the dimensions of an image are using PHP. I need to work out what the width and height are of an image which can be passed to PHP using a URL.

    Can anyone help?

    Thanks
    Phil
     
    Phil Vessey, Jan 23, 2007 IP
  2. sandris

    sandris Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think that php has function that can get dimensions of remote image. One way to get dimenstions:
    Download image file with php and check dimensions with GD(http://www.php.net/gd).
     
    sandris, Jan 23, 2007 IP
  3. Chemo

    Chemo Peon

    Messages:
    146
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
  4. smatts9

    smatts9 Active Member

    Messages:
    1,089
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    88
    #4
    
    <?php
    $info = getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif");
    echo $info[3];
    ?>
    
    Code (markup):
    I'm only displaying the Array[3], but there are your other options too, I tested it with Google's Logo.

    Array[0] = Width
    Array[1] = Height
    Array[2] = Image Type Flag
    Array[3] = width="xxx" height="xxx"
    Array[bits] = bits
    Array[channels] = channels
    Array[mime] = mime-type
     
    smatts9, Jan 23, 2007 IP