Fork me on GitHub

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