grab — Crop and resize combined

Description

public Intervention\Image\Image grab(int $width, int $height)

Combine cropping and resizing to format image in a smart way. The method will find the best fitting aspect ratio of your given width and height on the current image automatically, cut it out and resize it to the given dimension.

Parameters

width

The width the image will be resized to after cropping out the best fitting aspect ratio.

height

The height the image will be resized to after cropping out the best fitting aspect ratio.

Return Values

Instance of Intervention\Image\Image

Examples

  1. // open file a image resource
  2. $img = Image::make('public/foo.jpg');
  3. // crop the best fitting 5:3 (600x360) ratio and resize to 600x360 pixel
  4. $img->grab(600, 360);
  5. // crop the best fitting 1:1 ratio (200x200) and resize to 200x200 pixel
  6. $img->grab(200);

See also