public static function isGdFile($filename)
    {
        if (!is_file($filename) || !is_readable($filename)) {
            throw new \InvalidArgumentException(sprintf(
                    '"%s" Is Not A Readable File', $filename
            ));
        }
        $result = false;
        $f = null;
        if (($f = @fopen($filename, 'r'))) {
            if (($id = @fread($f, 3))) {
                $result = ('gd2' === strtolower($id)) ? true : false;
            }
        }
        @fclose($f);

        return $result;
    }
public static function isGdFile($filename)
    {
        if (!is_file($filename) || !is_readable($filename)) {
            throw new \InvalidArgumentException(sprintf(
                    '"%s" Is Not A Readable File', $filename
            ));
        }
        $result = false;
        $f = null;
        if (($f = @fopen($filename, 'r'))) {
            if (($id = @fread($f, 3))) {
                $result = ('gd2' === strtolower($id)) ? true : false;
            }
        }
        @fclose($f);

        return $result;
    }
public static function isGdFile ( $ filename ) { if ( ! is_file ( $ filename ) || ! is_readable ( $ filename ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" Is Not A Readable File' , $ filename ) ) ; } $ result = false ; $ f = null ; if ( ( $ f = @ fopen ( $ filename , 'r' ) ) ) { if ( ( $ id = @ fread ( $ f , 3 ) ) ) { $ result = ( 'gd2' === strtolower ( $ id ) ) ? true : false ; } } @ fclose ( $ f ) ; return $ result ; }
Check if the given file is gd file

@param string $filename

@return boolean                   true if gd file,false otherwise
@throws \InvalidArgumentException
Check if the given file is gd file