You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Color arguments can be passed in as any CSS color (e.g. `LightBlue`), a hex color, or an RGB(A) array.
53
-
- Support for alpha-transparency (GIF, PNG, WEBP)
53
+
- Support for alpha-transparency (GIF, PNG, WEBP, AVIF)
54
54
- Chainable methods
55
55
- Uses exceptions
56
56
- Load with Composer or manually (just one file)
@@ -141,52 +141,117 @@ Returns a SimpleImage object.
141
141
142
142
### Savers
143
143
144
-
#### `toDataUri($mimeType, $quality)`
144
+
#### `toDataUri($mimeType, $options)`
145
145
146
146
Generates a data URI.
147
147
148
148
-`$mimeType` (string) - The image format to output as a mime type (defaults to the original mime type).
149
-
-`$quality` (int) - Image quality as a percentage (default 100). This argument has no effect on PNG images, since the format is lossless.
149
+
-`$options` (array|int) - Array of options or Image quality as a percentage (default 100).
150
150
151
151
Returns a string containing a data URI.
152
152
153
-
#### `toDownload($filename, $mimeType, $quality)`
153
+
#### `toDownload($filename, $mimeType, $options)`
154
154
155
155
Forces the image to be downloaded to the clients machine. Must be called before any output is sent to the screen.
156
156
157
157
-`$filename`* (string) - The filename (without path) to send to the client (e.g. 'image.jpeg').
158
158
-`$mimeType` (string) - The image format to output as a mime type (defaults to the original mime type).
159
-
-`$quality` (int) - Image quality as a percentage (default 100). This argument has no effect on PNG images, since the format is lossless.
159
+
-`$options` (array|int) - Array of options or Image quality as a percentage (default 100).
160
160
161
161
Returns a SimpleImage object.
162
162
163
-
#### `toFile($file, $mimeType, $quality)`
163
+
#### `toFile($file, $mimeType, $options)`
164
164
165
165
Writes the image to a file.
166
166
167
167
-`$mimeType` (string) - The image format to output as a mime type (defaults to the original mime type).
168
-
-`$quality` (int) - Image quality as a percentage (default 100). This argument has no effect on PNG images, since the format is lossless.
168
+
-`$options` (array|int) - Array of options or Image quality as a percentage (default 100).
169
169
170
170
Returns a SimpleImage object.
171
171
172
-
#### `toScreen($mimeType, $quality)`
172
+
#### `toScreen($mimeType, $options)`
173
173
174
174
Outputs the image to the screen. Must be called before any output is sent to the screen.
175
175
176
176
-`$mimeType` (string) - The image format to output as a mime type (defaults to the original mime type).
177
-
-`$quality` (int) - Image quality as a percentage (default 100). This argument has no effect on PNG images, since the format is lossless.
177
+
-`$options` (array|int) - Array of options or Image quality as a percentage (default 100).
178
178
179
179
Returns a SimpleImage object.
180
180
181
-
#### `toString($mimeType, $quality)`
181
+
#### `toString($mimeType, $options)`
182
182
183
183
Generates an image string.
184
184
185
185
-`$mimeType` (string) - The image format to output as a mime type (defaults to the original mime type).
186
-
-`$quality` (int) - Image quality as a percentage (default 100). This argument has no effect on PNG images, since the format is lossless.
186
+
-`$options` (array|int) - Array of options or Image quality as a percentage (default 100).
187
187
188
188
Returns a SimpleImage object.
189
189
190
+
#### Options array
191
+
192
+
Instead of providing the quality as an integer as the last function parameter you can also set various options depending on the targeted Mime type using an associative array.
193
+
194
+
```php
195
+
$image->toFile($file, 'image/avif', [
196
+
// JPG, WEBP, AVIF (default 100)
197
+
'quality' => 100,
198
+
199
+
// AVIF (default -1 which is 6)
200
+
// range of slow and small file 0 to 10 fast but big file
201
+
'speed' => -1,
202
+
]);
203
+
```
204
+
205
+
```php
206
+
$image->toFile($file, 'image/bmp', [
207
+
// BMP: boolean (default true)
208
+
'compression' => true,
209
+
210
+
// BMP, JPG (default null, keep the same)
211
+
'interlace' => null,
212
+
]);
213
+
```
214
+
215
+
```php
216
+
$image->toFile($file, 'image/gif', [
217
+
// GIF, PNG (default true)
218
+
'alpha' => true,
219
+
]);
220
+
```
221
+
222
+
```php
223
+
$image->toFile($file, 'image/jpeg', [
224
+
// BMP, JPG (default null, keep the same)
225
+
'interlace' => null,
226
+
227
+
// JPG, WEBP, AVIF (default 100)
228
+
'quality' => 100,
229
+
]);
230
+
```
231
+
232
+
```php
233
+
$image->toFile($file, 'image/png', [
234
+
// GIF, PNG (default true)
235
+
'alpha' => true,
236
+
237
+
// PNG: 0-10, defaults to zlib (default 6)
238
+
'compression' => -1,
239
+
240
+
// PNG (default -1)
241
+
'filters' => -1,
242
+
243
+
// has no effect on PNG images, since the format is lossless
0 commit comments