|
| 1 | +# WMF |
| 2 | + |
| 3 | +You can load `.wmf` files. |
| 4 | + |
| 5 | +## Backends |
| 6 | + |
| 7 | +You can one of two current backends : `gd` or `imagick`. |
| 8 | +If you don't know which one used, you can use the magic one. |
| 9 | + |
| 10 | +```php |
| 11 | +<?php |
| 12 | + |
| 13 | +use PhpOffice\WMF\Reader\WMF\GD; |
| 14 | +use PhpOffice\WMF\Reader\WMF\Imagick; |
| 15 | +use PhpOffice\WMF\Reader\WMF\Magic; |
| 16 | + |
| 17 | +// Choose which backend you want |
| 18 | +$reader = new GD(); |
| 19 | +$reader = new Imagick(); |
| 20 | +$reader = new Magic(); |
| 21 | + |
| 22 | +$reader->load('sample.wmf'); |
| 23 | +``` |
| 24 | + |
| 25 | +For next sample, I will use the magic one. |
| 26 | + |
| 27 | +## Methods |
| 28 | + |
| 29 | +### `getResource` |
| 30 | + |
| 31 | +The method returns the resource used in internal by the library. |
| 32 | + |
| 33 | +The `GD` backend returns a `GDImage` object or resource, depending the PHP version. |
| 34 | +The `Imagick` backend returns a `Imagick` object. |
| 35 | + |
| 36 | +```php |
| 37 | +<?php |
| 38 | + |
| 39 | +use PhpOffice\WMF\Reader\WMF\Magic; |
| 40 | + |
| 41 | +$reader = new Magic(); |
| 42 | + |
| 43 | +$wmf = $reader->load('sample.wmf'); |
| 44 | + |
| 45 | +var_dump($wmf->getResource()); |
| 46 | +``` |
| 47 | + |
| 48 | +### `getMediaType` |
| 49 | + |
| 50 | +The method returns the media type for a WMF file |
| 51 | + |
| 52 | +```php |
| 53 | +<?php |
| 54 | + |
| 55 | +use PhpOffice\WMF\Reader\WMF\Magic; |
| 56 | + |
| 57 | +$reader = new Magic(); |
| 58 | + |
| 59 | +$mediaType = $reader->getMediaType(); |
| 60 | + |
| 61 | +echo 'The media type for a WMF file is ' . $$mediaType; |
| 62 | +``` |
| 63 | + |
| 64 | +### `isWMF` |
| 65 | + |
| 66 | +The method allows to know if the file is supported by the library. |
| 67 | + |
| 68 | +```php |
| 69 | +<?php |
| 70 | + |
| 71 | +use PhpOffice\WMF\Reader\WMF\Magic; |
| 72 | + |
| 73 | +$reader = new Magic(); |
| 74 | + |
| 75 | +$isWMF = $reader->isWMF('sample.wmf'); |
| 76 | + |
| 77 | +echo 'The file sample.wmf ' . ($isWMF ? 'is a WMF file' : 'is not a WMF file'); |
| 78 | +``` |
| 79 | + |
| 80 | +### `load` |
| 81 | + |
| 82 | +The method load a WMF file in the object |
| 83 | + |
| 84 | +```php |
| 85 | +<?php |
| 86 | + |
| 87 | +use PhpOffice\WMF\Reader\WMF\Magic; |
| 88 | + |
| 89 | +$reader = new Magic(); |
| 90 | + |
| 91 | +$wmf = $reader->load('sample.wmf'); |
| 92 | +``` |
| 93 | + |
| 94 | +### `save` |
| 95 | + |
| 96 | +The method transforms the loaded WMF file in an another image. |
| 97 | + |
| 98 | +```php |
| 99 | +<?php |
| 100 | + |
| 101 | +use PhpOffice\WMF\Reader\WMF\Magic; |
| 102 | + |
| 103 | +$reader = new Magic(); |
| 104 | + |
| 105 | +$wmf = $reader->load('sample.wmf'); |
| 106 | +$wmf->save('sample.png', 'png'); |
| 107 | +``` |
0 commit comments