Image Format Detection

Discussion in 'PHP' started by !Unreal, Mar 9, 2009.

  1. #1
    Im trying to detect the format of an image. But I get a parse error

    <?php
    $filename = 'http://static.php.net/www.php.net/images/php.gif';
    $file = fopen($filename, 'rb');
    $size = getimagesize($file);
            switch ($size['mime']) {
        case "IMAGETYPE_GIF":
            echo "Image is a gif";
            break;
        case "IMAGETYPE_JPEG":
            echo "Image is a jpeg";
            break;
        case "IMAGETYPE_PNG":
            echo "Image is a png";
            break;
    ?>
    PHP:

     
    !Unreal, Mar 9, 2009 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You didn't close the { that you opened on the switch() line.
     
    SmallPotatoes, Mar 9, 2009 IP
  3. !Unreal

    !Unreal Well-Known Member

    Messages:
    1,671
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    165
    #3
    yeah I just realised lol
     
    !Unreal, Mar 9, 2009 IP