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
+47-47Lines changed: 47 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,8 +33,8 @@ Service function:
33
33
34
34
The available Handlers are as follows:
35
35
36
-
- gd The GD/GD2 image library
37
-
- imagick The ImageMagick library.
36
+
- ``gd`` The GD/GD2 image library
37
+
- ``imagick`` The ImageMagick library.
38
38
39
39
If using the ImageMagick library, you must set the path to the library on your
40
40
server in **app/Config/Images.php**.
@@ -58,7 +58,7 @@ For example, to create an image thumbnail you'll do this:
58
58
The above code tells the library to look for an image
59
59
called *mypic.jpg* located in the source_image folder, then create a
60
60
new image from it that is 100 x 100pixels using the GD2 image_library,
61
-
and save it to a new file (the thumb). Since it is using the fit() method,
61
+
and save it to a new file (the thumb). Since it is using the ``fit()`` method,
62
62
it will attempt to find the best portion of the image to crop based on the
63
63
desired aspect ratio, and then crop and resize the result.
64
64
@@ -103,14 +103,14 @@ Processing Methods
103
103
104
104
There are seven available processing methods:
105
105
106
-
- $image->crop()
107
-
- $image->convert()
108
-
- $image->fit()
109
-
- $image->flatten()
110
-
- $image->flip()
111
-
- $image->resize()
112
-
- $image->rotate()
113
-
- $image->text()
106
+
- ``$image->crop()``
107
+
- ``$image->convert()``
108
+
- ``$image->fit()``
109
+
- ``$image->flatten()``
110
+
- ``$image->flip()``
111
+
- ``$image->resize()``
112
+
- ``$image->rotate()``
113
+
- ``$image->text()``
114
114
115
115
These methods return the class instance so they can be chained together, as shown above.
116
116
If they fail they will throw a ``CodeIgniter\Images\ImageException`` that contains
@@ -127,12 +127,12 @@ thumbnail images that should match a certain size/aspect ratio. This is handled
127
127
128
128
crop(int $width = null, int $height = null, int $x = null, int $y = null, bool $maintainRatio = false, string $masterDim = 'auto')
129
129
130
-
- **$width** is the desired width of the resulting image, in pixels.
131
-
- **$height** is the desired height of the resulting image, in pixels.
132
-
- **$x** is the number of pixels from the left side of the image to start cropping.
133
-
- **$y** is the number of pixels from the top of the image to start cropping.
134
-
- **$maintainRatio** will, if true, adjust the final dimensions as needed to maintain the image's original aspect ratio.
135
-
- **$masterDim** specifies which dimension should be left untouched when $maintainRatio is true. Values can be: 'width', 'height', or 'auto'.
130
+
- ``$width`` is the desired width of the resulting image, in pixels.
131
+
- ``$height`` is the desired height of the resulting image, in pixels.
132
+
- ``$x`` is the number of pixels from the left side of the image to start cropping.
133
+
- ``$y`` is the number of pixels from the top of the image to start cropping.
134
+
- ``$maintainRatio`` will, if true, adjust the final dimensions as needed to maintain the image's original aspect ratio.
135
+
- ``$masterDim`` specifies which dimension should be left untouched when ``$maintainRatio`` is true. Values can be: ``'width'``, ``'height'``, or ``'auto'``.
136
136
137
137
To take a 50x50 pixel square out of the center of an image, you would need to first calculate the appropriate x and y
138
138
offset values:
@@ -146,12 +146,12 @@ The ``convert()`` method changes the library's internal indicator for the desire
146
146
147
147
convert(int $imageType)
148
148
149
-
- **$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):
149
+
- ``$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):
150
150
151
151
.. literalinclude:: images/009.php
152
152
153
153
.. note:: ImageMagick already saves files in the type
154
-
indicated by their extension, ignoring **$imageType**
154
+
indicated by their extension, ignoring ``$imageType``.
155
155
156
156
Fitting Images
157
157
--------------
@@ -166,9 +166,9 @@ The ``fit()`` method aims to help simplify cropping a portion of an image in a "
166
166
167
167
fit(int $width, int $height = null, string $position = 'center')
168
168
169
-
- **$width** is the desired final width of the image.
170
-
- **$height** is the desired final height of the image.
171
-
- **$position** determines the portion of the image to crop out. Allowed positions: 'top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'.
169
+
- ``$width`` is the desired final width of the image.
170
+
- ``$height`` is the desired final height of the image.
171
+
- ``$position`` determines the portion of the image to crop out. Allowed positions: ``'top-left'``, ``'top'``, ``'top-right'``, ``'left'``, ``'center'``, ``'right'``, ``'bottom-left'``, ``'bottom'``, ``'bottom-right'``.
172
172
173
173
This provides a much simpler way to crop that will always maintain the aspect ratio:
174
174
@@ -185,9 +185,9 @@ The ``flatten()`` method aims to add a background color behind transparent image
185
185
186
186
flatten(int $red = 255, int $green = 255, int $blue = 255)
187
187
188
-
- **$red** is the red value of the background.
189
-
- **$green** is the green value of the background.
190
-
- **$blue** is the blue value of the background.
188
+
- ``$red`` is the red value of the background.
189
+
- ``$green`` is the green value of the background.
190
+
- ``$blue`` is the blue value of the background.
191
191
192
192
.. literalinclude:: images/011.php
193
193
@@ -198,44 +198,44 @@ Images can be flipped along either their horizontal or vertical axis::
198
198
199
199
flip(string $dir)
200
200
201
-
- **$dir** specifies the axis to flip along. Can be either 'vertical' or 'horizontal'.
201
+
- ``$dir`` specifies the axis to flip along. Can be either ``'vertical'`` or ``'horizontal'``.
202
202
203
203
.. literalinclude:: images/012.php
204
204
205
205
Resizing Images
206
206
---------------
207
207
208
-
Images can be resized to fit any dimension you require with the resize() method::
208
+
Images can be resized to fit any dimension you require with the ``resize()`` method::
0 commit comments