The width and height of the Image can be modified by calling the width and height functions and passing in the desired dimensions in pixels. The resized image will be contained within the given $width and $height dimensions respecting the original aspect ratio.
Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio, and will also not increase the size of the image if it is smaller than the output size.
Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions.
# Example of how to set background colour to fill remaining pixels$image->fit(Manipulations::FIT_FILL, 497, 290)->background('007698');
Resizes the image to fit within the width and height boundaries without cropping but upscaling the image if it’s smaller. The finished image will have remaining space on either width or height (except if the aspect ratio of the new image is the same as the old image). The remaining space will be filled with the background color. The resulting image will match the constraining dimensions.
By calling the crop method part of the image will be cropped to the given $width and $height dimensions (pixels). Use the $cropMethod to specify which part will be cropped out.
$image->crop(string $cropMethod, int $width, int $height);
The following $cropMethods are available through constants of the Manipulations class:
CROP_TOP_LEFT, CROP_TOP, CROP_TOP_RIGHT, CROP_LEFT, CROP_CENTER, CROP_RIGHT, CROP_BOTTOM_LEFT, CROP_BOTTOM, CROP_BOTTOM_RIGHT.
The focalCrop method can be used to crop around an exact position. The center of the crop is controlled by the $focalX and $focalY values in percent (0 - 100).
You can also zoom into your focal point, if needed. Zoom is controlled by a floating point ranging from 1 to 100. Each step represents a 100% zoom, so passing 2 will be the same as viewing the image at 200%. The suggested range is 1-10.
$image->focalCrop(int $width, int $height, int $focalX, int $focalY, float $zoom =1);