Skip to content

Commit 0cdfffb

Browse files
authored
Add convert() usage to docs
1 parent 9fe563f commit 0cdfffb

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

user_guide_src/source/libraries/images.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ starting at the top left corner. The result would be saved as the thumbnail.
9292
Processing Methods
9393
==================
9494

95-
There are six available processing methods:
95+
There are seven available processing methods:
9696

9797
- $image->crop()
98+
- $image->convert()
9899
- $image->fit()
99100
- $image->flatten()
100101
- $image->flip()
@@ -155,6 +156,22 @@ offset values::
155156
->crop(50, 50, $xOffset, $yOffset)
156157
->save('path/to/new/image.jpg');
157158

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**
174+
158175
Fitting Images
159176
--------------
160177

0 commit comments

Comments
 (0)