Documentation

Metafile
in package

Windows metafiles (WMF, EMF & EMF+) helper, based on phpoffice/wmf.

The support is optional : it requires the phpoffice/wmf library and the GD extension.

EMF+ files are EMF files containing EMF+ records : they are stored as EMF files. The GD readers are used : they are pure PHP and don't depend on external delegates (like Imagick).

Table of Contents

Constants

MIME_EMF  : mixed = 'image/x-emf'
MIME_WMF  : mixed = 'image/x-wmf'

Methods

convertToPng()  : string|null
Converts a metafile to PNG.
getExtension()  : string|null
Returns the extension of a metafile mime type (`wmf` or `emf`).
getImageSize()  : null|array{0: int, 1: int, 2: string}
Returns the size of a metafile and its mime type, like getimagesize() : [width, height, mimeType].
getMimeType()  : string|null
Returns the mime type of a metafile (`image/x-wmf` or `image/x-emf`).
isMimeType()  : bool
Returns if the mime type is the one of a metafile.
isSupported()  : bool
Returns if the metafiles are supported : phpoffice/wmf is installed and the GD extension is loaded.
load()  : null|GD|GD

Constants

MIME_EMF

public mixed MIME_EMF = 'image/x-emf'

MIME_WMF

public mixed MIME_WMF = 'image/x-wmf'

Methods

convertToPng()

Converts a metafile to PNG.

public static convertToPng(string $content) : string|null

Returns null if the content is not a metafile, if it can't be read or if the metafiles are not supported.

Parameters
$content : string
Return values
string|null

getExtension()

Returns the extension of a metafile mime type (`wmf` or `emf`).

public static getExtension(string $mimeType) : string|null
Parameters
$mimeType : string
Return values
string|null

getImageSize()

Returns the size of a metafile and its mime type, like getimagesize() : [width, height, mimeType].

public static getImageSize(string $content) : null|array{0: int, 1: int, 2: string}

Returns null if the content is not a metafile, if it can't be read or if the metafiles are not supported.

Parameters
$content : string
Return values
null|array{0: int, 1: int, 2: string}

getMimeType()

Returns the mime type of a metafile (`image/x-wmf` or `image/x-emf`).

public static getMimeType(string $content) : string|null

Returns null if the content is not a metafile or if the metafiles are not supported.

Parameters
$content : string
Return values
string|null

isMimeType()

Returns if the mime type is the one of a metafile.

public static isMimeType(string|null $mimeType) : bool
Parameters
$mimeType : string|null
Return values
bool

isSupported()

Returns if the metafiles are supported : phpoffice/wmf is installed and the GD extension is loaded.

public static isSupported() : bool
Return values
bool

load()

private static load(string $content, string $mimeType) : null|GD|GD
Parameters
$content : string
$mimeType : string
Return values
null|GD|GD
On this page

Search results