public static function dompdf_getimagesize($filename, $context = null)
    {
        static $cache = array();

        if (isset($cache[$filename])) {
            return $cache[$filename];
        }

        list($width, $height, $type) = getimagesize($filename);

        // Custom types
        $types = array(
            IMAGETYPE_JPEG => "jpeg",
            IMAGETYPE_GIF  => "gif",
            IMAGETYPE_BMP  => "bmp",
            IMAGETYPE_PNG  => "png",
        );

        $type = isset($types[$type]) ? $types[$type] : null;

        if ($width == null || $height == null) {
            list($data, $headers) = Helpers::getFileContent($filename, $context);

            if (substr($data, 0, 2) === "BM") {
                $meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
                $width = (int)$meta['width'];
                $height = (int)$meta['height'];
                $type = "bmp";
            }
            else {
                if (strpos($data, "<svg") !== false) {
                    $doc = new \Svg\Document();
                    $doc->loadFile($filename);

                    list($width, $height) = $doc->getDimensions();
                    $type = "svg";
                }
            }

        }

        return $cache[$filename] = array($width, $height, $type);
    }
public static function dompdf_getimagesize($filename, $context = null)
    {
        static $cache = array();

        if (isset($cache[$filename])) {
            return $cache[$filename];
        }

        list($width, $height, $type) = getimagesize($filename);

        // Custom types
        $types = array(
            IMAGETYPE_JPEG => "jpeg",
            IMAGETYPE_GIF  => "gif",
            IMAGETYPE_BMP  => "bmp",
            IMAGETYPE_PNG  => "png",
        );

        $type = isset($types[$type]) ? $types[$type] : null;

        if ($width == null || $height == null) {
            list($data, $headers) = Helpers::getFileContent($filename, $context);

            if (substr($data, 0, 2) === "BM") {
                $meta = unpack('vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight', $data);
                $width = (int)$meta['width'];
                $height = (int)$meta['height'];
                $type = "bmp";
            }
            else {
                if (strpos($data, "<svg") !== false) {
                    $doc = new \Svg\Document();
                    $doc->loadFile($filename);

                    list($width, $height) = $doc->getDimensions();
                    $type = "svg";
                }
            }

        }

        return $cache[$filename] = array($width, $height, $type);
    }
public static function dompdf_getimagesize ( $ filename , $ context = null ) { static $ cache = array ( ) ; if ( isset ( $ cache [ $ filename ] ) ) { return $ cache [ $ filename ] ; } list ( $ width , $ height , $ type ) = getimagesize ( $ filename ) ; // Custom types $ types = array ( IMAGETYPE_JPEG => "jpeg" , IMAGETYPE_GIF => "gif" , IMAGETYPE_BMP => "bmp" , IMAGETYPE_PNG => "png" , ) ; $ type = isset ( $ types [ $ type ] ) ? $ types [ $ type ] : null ; if ( $ width == null || $ height == null ) { list ( $ data , $ headers ) = Helpers :: getFileContent ( $ filename , $ context ) ; if ( substr ( $ data , 0 , 2 ) === "BM" ) { $ meta = unpack ( 'vtype/Vfilesize/Vreserved/Voffset/Vheadersize/Vwidth/Vheight' , $ data ) ; $ width = ( int ) $ meta [ 'width' ] ; $ height = ( int ) $ meta [ 'height' ] ; $ type = "bmp" ; } else { if ( strpos ( $ data , "<svg" ) !== false ) { $ doc = new \ Svg \ Document ( ) ; $ doc -> loadFile ( $ filename ) ; list ( $ width , $ height ) = $ doc -> getDimensions ( ) ; $ type = "svg" ; } } } return $ cache [ $ filename ] = array ( $ width , $ height , $ type ) ; }
getimagesize doesn't give a good size for 32bit BMP image v5

@param string $filename
@param resource $context
@return array The same format as getimagesize($filename)
getimagesize doesn t give a good size for 32bit BMP image v5