resize — Resize current image
Description
public Intervention\Image\Image resize ( integer $width, integer $height, [boolean $ratio, [boolean $upsize]] )
Resizes current image based on given width and/or height
Parameters
width
The new width of the image
height
The new height of the image
ratio (optional)
If ratio is set to boolean
true the aspect ratio of the image will be preserved during the resize process. Default: false
upsize (optional)
Determines whether the image can be upsized. Set to boolean false if you want upsizing being prevented. Default: true
Return Values
Resized instance of Intervention\Image
Examples
// resize image to fixed size
$img = Image::make('public/foo.jpg')->resize(300, 200);
// resize only the width of the imag
$img = Image::make('public/foo.jpg')->resize(300, null);
// resize only the height of the imag
$img = Image::make('public/foo.jpg')->resize(null, 200);
// resize the image to a width of 300 and constrain aspect ratio (auto height)
$img = Image::make('public/foo.jpg')->resize(300, null, true);
// resize the image to a height of 200 and constrain aspect ratio (auto width)
$img = Image::make('public/foo.jpg')->resize(null, 200, true);
// prevent possible upsizing with optional fourth parameter
$img = Image::make('public/foo.jpg')->resize(null, 400, true, false);
See also
当前内容版权归 intervention 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 intervention .