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
Keep in mind that most public methods return a `JImage` instance with a valid image handle for easy method chaining. The examples for each method will break each method call out to be able to comment on what the code is doing, but production code can be chained like so (if you prefer):
Since Platform version 12.3, there is a new `destroy()` method that get's called in appropriate places throughout the class which runs the `imagedestroy` function to free memory associated with an image handle. This method is called before each time an image handle is replaced (when `$createNew` is set to false) as well as in the class `__descruct` method as a final cleanup.
45
+
46
+
47
+
#### The `resize` method
48
+
__Accepted Parameters__
49
+
*`$width`: The width of the resized image in pixels or a percentage.
50
+
*`$height`: The height of the resized image in pixels or a percentage.
51
+
*`$createNew`: If true the current image will be cloned, resized and returned; else the current image will be resized and returned.
52
+
*`$scaleMethod`: Which method to use for scaling
53
+
54
+
Example: Using `JImage::resize()` to generate a resized image.
55
+
56
+
```php
57
+
// Create our image object
58
+
$image = new JImage(JPATH_SITE . '/media/com_foo/images/uploads/bar.png');
In this example, we use the `createThumbs` method of `JImage`. This method takes 2 parameters. The first parameter can be a string containing a single size in `WIDTHxHEIGHT` format, or it can be an array of sizes in the format (as shown in the example). The second parameter specifizes the resize method, and is one of the following:
110
+
In this example, we use the `createThumbs` method of `JImage`. This method takes 2 parameters. The first parameter can be a string containing a single size in `WIDTHxHEIGHT` format, or it can be an array of sizes in the format (as shown in the example). The second parameter specifizes the resize method. (See Resize Methods below)
111
+
112
+
113
+
#### Resize Methods
114
+
115
+
The `resize`, `createThumbs` and `generateThumbs` methods take an optional parameter that defines what method to use when scaling an image.
116
+
This parameter can be one of the following:
54
117
55
118
*`JImage::SCALE_FILL` - Gives you a thumbnail of the exact size, stretched or squished to fit the parameters.
56
119
*`JImage::SCALE_INSIDE` - Fits your thumbnail within your given parameters. It will not be any taller or wider than the size passed, whichever is larger.
0 commit comments