Trim::resizeFill
Resize the image with keeping ratio and filling the empty area (Like
object-fit: contain)
Description
public void Trim::resizeFill( int $w, int $h )
The output is exactly $w x $h. The image is scaled down to fit in it, keeping its aspect ratio, and placed in the center. The empty area is white for JPEG output and transparent for PNG output from a PNG source. Images smaller than the specified size are not enlarged. 0 means the original width or height.
Arguments
| Name | Data type | Default | Remarks |
|---|---|---|---|
| $w | int | Output width / 0: original width | |
| $h | int | Output height / 0: original height |
Example
Controller
use Fegg\Tool\Trim;
$trim = new Trim();
$trim->setImage('path/to/image.png', 'path/to/converted.png');
$trim->resizeFill(300, 300);
$trim->create();