public function dimensions() {
        return $this->_cache(__FUNCTION__, function($file) {
            /** @type \Transit\File $file */

            $dims = null;

            if (!$file->isImage()) {
                return $dims;
            }

            $data = @getimagesize($file->path());

            if ($data && is_array($data)) {
                $dims = array(
                    'width' => $data[0],
                    'height' => $data[1]
                );
            }

            if (!$data) {
                $image = @imagecreatefromstring(file_get_contents($file->path()));
                $dims = array(
                    'width' => @imagesx($image),
                    'height' => @imagesy($image)
                );
            }

            return $dims;
        });
    }
public function dimensions() {
        return $this->_cache(__FUNCTION__, function($file) {
            /** @type \Transit\File $file */

            $dims = null;

            if (!$file->isImage()) {
                return $dims;
            }

            $data = @getimagesize($file->path());

            if ($data && is_array($data)) {
                $dims = array(
                    'width' => $data[0],
                    'height' => $data[1]
                );
            }

            if (!$data) {
                $image = @imagecreatefromstring(file_get_contents($file->path()));
                $dims = array(
                    'width' => @imagesx($image),
                    'height' => @imagesy($image)
                );
            }

            return $dims;
        });
    }
public function dimensions ( ) { return $ this -> _cache ( __FUNCTION__ , function ( $ file ) { /** @type \Transit\File $file */ $ dims = null ; if ( ! $ file -> isImage ( ) ) { return $ dims ; } $ data = @ getimagesize ( $ file -> path ( ) ) ; if ( $ data && is_array ( $ data ) ) { $ dims = array ( 'width' => $ data [ 0 ] , 'height' => $ data [ 1 ] ) ; } if ( ! $ data ) { $ image = @ imagecreatefromstring ( file_get_contents ( $ file -> path ( ) ) ) ; $ dims = array ( 'width' => @ imagesx ( $ image ) , 'height' => @ imagesy ( $ image ) ) ; } return $ dims ; } ) ; }
Return the dimensions of the file if it is an image.

@return array
Return the dimensions of the file if it is an image .