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
Copy file name to clipboardExpand all lines: user_guide_src/source/libraries/images.rst
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,9 +92,10 @@ starting at the top left corner. The result would be saved as the thumbnail.
92
92
Processing Methods
93
93
==================
94
94
95
-
There are six available processing methods:
95
+
There are seven available processing methods:
96
96
97
97
- $image->crop()
98
+
- $image->convert()
98
99
- $image->fit()
99
100
- $image->flatten()
100
101
- $image->flip()
@@ -155,6 +156,22 @@ offset values::
155
156
->crop(50, 50, $xOffset, $yOffset)
156
157
->save('path/to/new/image.jpg');
157
158
159
+
Converting Images
160
+
-----------------
161
+
162
+
The ``convert()`` method changes the library's internal indicator for the desired file format. This doesn't touch the actual image resource, but indicates to ``save()`` what format to use.
163
+
164
+
convert(int $imageType)
165
+
166
+
- **$imageType** is one of PHP's image type constants (see for example https://www.php.net/manual/en/function.image-type-to-mime-type.php)
167
+
168
+
Services::image()
169
+
->withFile('/path/to/image/mypic.jpg')
170
+
->convert(IMAGETYPE_PNG)
171
+
->save('path/to/new/image.png');
172
+
173
+
.. note:: ImageMagick already saves files in the type indicated by their extension, ignoring **$imageType**
0 commit comments