Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Description
public Intervention\Image\Image resize (integer $width, integer $height, [Closure $callback])
Resizes current image based on given width and/or height. To constraint the resize command, pass an optional
Closure callback as third parameter.
Parameters
width
height
callback (optional)
Closure callback defining constraints on the resize. It's possible to constraint the aspect-ratio and/or a
unwanted upsizing of the image. See examples below.
aspectRatio
Constraint the current aspect-ratio of the image. As a shortcut to proportional resizing you can use widen() or heighten().
upsize
Return Values
Instance of Intervention\Image\Image
Examples
// create instance
$img = Image::make('public/foo.jpg')
$img->resize(300, 200);
$img->resize(300, null);
$img->resize(null, 200);
// resize the image to a width of 300 and constrain aspect ratio (auto height)
$constraint->aspectRatio();
});
// resize the image to a height of 200 and constrain aspect ratio (auto width)
$constraint->aspectRatio();
});
$constraint->aspectRatio();
$constraint->upsize();
});