@@ -7,6 +7,9 @@ You can load `.wmf` files.
77You can one of two current backends : ` gd ` or ` imagick ` .
88If you don't know which one used, you can use the magic one.
99
10+ By default, the order of the backends is Imagick, followed by GD.
11+ Each backend is tested on different criteria: extension loaded, format support.
12+
1013``` php
1114<?php
1215
@@ -22,7 +25,41 @@ $reader = new Magic();
2225$reader->load('sample.wmf');
2326```
2427
25- For next sample, I will use the magic one.
28+ For next samples, I will use the magic one.
29+
30+ ### ` getBackends `
31+
32+ This specific method for ` Magic::class ` returns backends sorted by priority.
33+
34+ ``` php
35+ <?php
36+
37+ use PhpOffice\WMF\Reader\WMF\Magic;
38+
39+ $reader = new Magic();
40+
41+ var_dump($reader->getBackends());
42+ ```
43+
44+ ### ` setBackends `
45+
46+ This specific method for ` Magic::class ` defines backends sorted by priority.
47+
48+ ``` php
49+ <?php
50+
51+ use PhpOffice\WMF\Reader\WMF\GD;
52+ use PhpOffice\WMF\Reader\WMF\Imagick;
53+ use PhpOffice\WMF\Reader\WMF\Magic;
54+
55+ $reader = new Magic();
56+ $reader->setBackends([
57+ GD::class,
58+ Imagick::class,
59+ ]);
60+
61+ var_dump($reader->getBackends());
62+ ```
2663
2764## Methods
2865
@@ -39,15 +76,14 @@ The `Imagick` backend returns a `Imagick` object.
3976use PhpOffice\WMF\Reader\WMF\Magic;
4077
4178$reader = new Magic();
79+ $reader->load('sample.wmf');
4280
43- $wmf = $reader->load('sample.wmf');
44-
45- var_dump($wmf->getResource());
81+ var_dump($reader->getResource());
4682```
4783
4884### ` getMediaType `
4985
50- The method returns the media type for a WMF file
86+ The method returns the media type for a WMF file.
5187
5288``` php
5389<?php
@@ -63,32 +99,47 @@ echo 'The media type for a WMF file is ' . $$mediaType;
6399
64100### ` isWMF `
65101
66- The method allows to know if the file is supported by the library.
102+ The method returns if the file is supported by the library.
67103
68104``` php
69105<?php
70106
71107use PhpOffice\WMF\Reader\WMF\Magic;
72108
73109$reader = new Magic();
110+ $reader->load('sample.wmf');
74111
75- $isWMF = $reader->isWMF('sample.wmf' );
112+ $isWMF = $reader->isWMF();
76113
77114echo 'The file sample.wmf ' . ($isWMF ? 'is a WMF file' : 'is not a WMF file');
78115```
79116
80117### ` load `
81118
82- The method load a WMF file in the object
119+ The method loads a WMF file in the object.
120+ The method returns ` true ` if the file has been correctly loaded, or ` false ` if it has not.
83121
84122``` php
85123<?php
86124
87125use PhpOffice\WMF\Reader\WMF\Magic;
88126
89127$reader = new Magic();
128+ $reader->load('sample.wmf');
129+ ```
90130
91- $wmf = $reader->load('sample.wmf');
131+ ### ` loadFromString `
132+
133+ The method loads a WMF file in the object from a string.
134+ The method returns ` true ` if the file has been correctly loaded, or ` false ` if it has not.
135+
136+ ``` php
137+ <?php
138+
139+ use PhpOffice\WMF\Reader\WMF\Magic;
140+
141+ $reader = new Magic();
142+ $reader->loadFromString(file_get_contents('sample.wmf'));
92143```
93144
94145### ` save `
@@ -101,7 +152,6 @@ The method transforms the loaded WMF file in an another image.
101152use PhpOffice\WMF\Reader\WMF\Magic;
102153
103154$reader = new Magic();
104-
105- $wmf = $reader->load('sample.wmf');
106- $wmf->save('sample.png', 'png');
155+ $reader->load('sample.wmf');
156+ $reader->save('sample.png', 'png');
107157```
0 commit comments