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

  1. // resize image to fixed size
  2. $img = Image::make('public/foo.jpg')->resize(300, 200);
  3. // resize only the width of the imag
  4. $img = Image::make('public/foo.jpg')->resize(300, null);
  5. // resize only the height of the imag
  6. $img = Image::make('public/foo.jpg')->resize(null, 200);
  7. // resize the image to a width of 300 and constrain aspect ratio (auto height)
  8. $img = Image::make('public/foo.jpg')->resize(300, null, true);
  9. // resize the image to a height of 200 and constrain aspect ratio (auto width)
  10. $img = Image::make('public/foo.jpg')->resize(null, 200, true);
  11. // prevent possible upsizing with optional fourth parameter
  12. $img = Image::make('public/foo.jpg')->resize(null, 400, true, false);

See also