protected function parseSizeForSvg()
    {
        $this->stream->resetPointer();

        // Keep reading bytes until we find the complete <svg> start tag.
        $inside = false;
        $markup = '';
        while ( true ) {
            $byte = $this->stream->read(1);

            // Open a tag if not in a tag and the byte is '<'.
            if ( ! $inside && '<' === $byte ) {
                $inside = true;
                $markup .= $byte;
            }
            // Close the current tag if the tag is open, the byte is '>', and the last characters weren't a comment token.
            elseif ( $inside && '>' === $byte && '--' !== substr( $markup, -2 ) ) {

                $inside = false;
                $markup .= $byte;

                // Break the loop if this tag started with '<svg', as we have now found the SVG start tag.
                if ( '<svg' === strtolower( substr( $markup, 0, 4 ) ) ) {
                    break;
                }

                // Clear out the markup since we consumed the end of the tag/comment.
                $markup = '';
            }
            // Append the bte to the current tag if the tag is open.
            elseif ( $inside ) {
                $markup .= $byte;
            }
        }

        $width = null;
        $height = null;
        if ( preg_match( '/\swidth=([\'"])(\d+(\.\d+)?)(px)?\1/', $markup, $matches ) ) {
            $width = floatval( $matches[2] );
        }
        if ( preg_match( '/\sheight=([\'"])(\d+(\.\d+)?)(px)?\1/', $markup, $matches ) ) {
            $height = floatval( $matches[2] );
        }
        if ( $width && $height ) {
            return [ $width, $height ];
        }
        if ( preg_match( '/\sviewBox=([\'"])[^\1]*(?:,|\s)+(?P<width>\d+(?:\.\d+)?)(?:px)?(?:,|\s)+(?P<height>\d+(?:\.\d+)?)(?:px)?\s*\1/', $markup, $matches ) ) {
            return [
                floatval( $matches['width'] ),
                floatval( $matches['height'] )
            ];
        }
        return null;
    }
protected function parseSizeForSvg()
    {
        $this->stream->resetPointer();

        // Keep reading bytes until we find the complete <svg> start tag.
        $inside = false;
        $markup = '';
        while ( true ) {
            $byte = $this->stream->read(1);

            // Open a tag if not in a tag and the byte is '<'.
            if ( ! $inside && '<' === $byte ) {
                $inside = true;
                $markup .= $byte;
            }
            // Close the current tag if the tag is open, the byte is '>', and the last characters weren't a comment token.
            elseif ( $inside && '>' === $byte && '--' !== substr( $markup, -2 ) ) {

                $inside = false;
                $markup .= $byte;

                // Break the loop if this tag started with '<svg', as we have now found the SVG start tag.
                if ( '<svg' === strtolower( substr( $markup, 0, 4 ) ) ) {
                    break;
                }

                // Clear out the markup since we consumed the end of the tag/comment.
                $markup = '';
            }
            // Append the bte to the current tag if the tag is open.
            elseif ( $inside ) {
                $markup .= $byte;
            }
        }

        $width = null;
        $height = null;
        if ( preg_match( '/\swidth=([\'"])(\d+(\.\d+)?)(px)?\1/', $markup, $matches ) ) {
            $width = floatval( $matches[2] );
        }
        if ( preg_match( '/\sheight=([\'"])(\d+(\.\d+)?)(px)?\1/', $markup, $matches ) ) {
            $height = floatval( $matches[2] );
        }
        if ( $width && $height ) {
            return [ $width, $height ];
        }
        if ( preg_match( '/\sviewBox=([\'"])[^\1]*(?:,|\s)+(?P<width>\d+(?:\.\d+)?)(?:px)?(?:,|\s)+(?P<height>\d+(?:\.\d+)?)(?:px)?\s*\1/', $markup, $matches ) ) {
            return [
                floatval( $matches['width'] ),
                floatval( $matches['height'] )
            ];
        }
        return null;
    }
protected function parseSizeForSvg ( ) { $ this -> stream -> resetPointer ( ) ; // Keep reading bytes until we find the complete <svg> start tag. $ inside = false ; $ markup = '' ; while ( true ) { $ byte = $ this -> stream -> read ( 1 ) ; // Open a tag if not in a tag and the byte is '<'. if ( ! $ inside && '<' === $ byte ) { $ inside = true ; $ markup .= $ byte ; } // Close the current tag if the tag is open, the byte is '>', and the last characters weren't a comment token. elseif ( $ inside && '>' === $ byte && '--' !== substr ( $ markup , - 2 ) ) { $ inside = false ; $ markup .= $ byte ; // Break the loop if this tag started with '<svg', as we have now found the SVG start tag. if ( '<svg' === strtolower ( substr ( $ markup , 0 , 4 ) ) ) { break ; } // Clear out the markup since we consumed the end of the tag/comment. $ markup = '' ; } // Append the bte to the current tag if the tag is open. elseif ( $ inside ) { $ markup .= $ byte ; } } $ width = null ; $ height = null ; if ( preg_match ( '/\swidth=([\'"])(\d+(\.\d+)?)(px)?\1/' , $ markup , $ matches ) ) { $ width = floatval ( $ matches [ 2 ] ) ; } if ( preg_match ( '/\sheight=([\'"])(\d+(\.\d+)?)(px)?\1/' , $ markup , $ matches ) ) { $ height = floatval ( $ matches [ 2 ] ) ; } if ( $ width && $ height ) { return [ $ width , $ height ] ; } if ( preg_match ( '/\sviewBox=([\'"])[^\1]*(?:,|\s)+(?P<width>\d+(?:\.\d+)?)(?:px)?(?:,|\s)+(?P<height>\d+(?:\.\d+)?)(?:px)?\s*\1/' , $ markup , $ matches ) ) { return [ floatval ( $ matches [ 'width' ] ) , floatval ( $ matches [ 'height' ] ) ] ; } return null ; }
Parse size for SVG.

@return array|null Size or null.
Parse size for SVG .