Image manipulation service.
More...
Image manipulation service.
- Since
- 2.3
Definition at line 20 of file ImageService.php.
◆ __construct()
◆ assertValidImageDimensions()
| Elgg\ImageService::assertValidImageDimensions |
( |
string |
$path | ) |
|
|
protected |
Assert that the source image has valid dimensions.
This can help prevent OOM issues during resizing
- Parameters
-
| string | $path | path to the image to validate |
- Returns
- void
- Exceptions
-
| InvalidArgumentException | |
| RangeException | |
- Since
- 7.0
Definition at line 329 of file ImageService.php.
◆ fixOrientation()
| Elgg\ImageService::fixOrientation |
( |
string |
$filename | ) |
|
If needed the image will be rotated based on orientation information.
- Parameters
-
| string | $filename | Path to image |
- Returns
- bool
Definition at line 145 of file ImageService.php.
◆ getFileFormat()
| Elgg\ImageService::getFileFormat |
( |
|
$filename, |
|
|
|
$params |
|
) |
| |
|
protected |
Determine the image file format, this is needed for correct resizing.
- Parameters
-
| string | $filename | path to the file |
| array | $params | array of resizing params (can contain 'format' to set save format) |
- See also
- https://github.com/Elgg/Elgg/issues/10686
- Returns
- void|string
Definition at line 273 of file ImageService.php.
◆ hasWebPSupport()
| Elgg\ImageService::hasWebPSupport |
( |
| ) |
|
Checks if imagine has WebP support.
- Returns
- bool
Definition at line 304 of file ImageService.php.
◆ normalizeResizeParameters()
| Elgg\ImageService::normalizeResizeParameters |
( |
string |
$source, |
|
|
array |
$params = [] |
|
) |
| |
Calculate the parameters for resizing an image.
- Parameters
-
| string | $source | The source location of the image to validate the parameters for |
| array | $params | Resize parameters
- 'w' maximum width of the resized image
- 'h' maximum height of the resized image
- 'upscale' allow upscaling
- 'square' constrain to a square
- 'x1', 'y1', 'x2', 'y2' cropping coordinates
|
- Returns
- array
- Exceptions
-
| InvalidArgumentException | |
| RangeException | |
Definition at line 184 of file ImageService.php.
◆ resize()
| Elgg\ImageService::resize |
( |
string |
$source, |
|
|
?string |
$destination = null, |
|
|
array |
$params = [] |
|
) |
| |
Crop and resize an image.
- Parameters
-
| string | $source | Path to source image |
| null | string | $destination | Path to destination If not set, will modify the source image |
| array | $params | An array of cropping/resizing parameters
- INT 'w' represents the width of the new image With upscaling disabled, this is the maximum width of the new image (in case the source image is smaller than the expected width)
- INT 'h' represents the height of the new image With upscaling disabled, this is the maximum height
- INT 'x1', 'y1', 'x2', 'y2' represent optional cropping coordinates. The source image will first be cropped to these coordinates, and then resized to match width/height parameters
- BOOL 'square' - square images will fill the bounding box (width x height). In Imagine's terms, this equates to OUTBOUND mode
- BOOL 'upscale' - if enabled, smaller images will be upscaled to fit the bounding box.
|
- Returns
- bool
Definition at line 83 of file ImageService.php.
◆ $imagine
| Elgg\ImageService::$imagine |
|
protected |
◆ JPEG_QUALITY
| const Elgg\ImageService::JPEG_QUALITY = 75 |
◆ WEBP_QUALITY
| const Elgg\ImageService::WEBP_QUALITY = 75 |
The documentation for this class was generated from the following file: