---
application: "Intervention Image"
version: "Version 2"
status: "eol"
---

# Image::crop

## Cut out a rectangular part of the current image



> public Intervention\Image\Image crop(int $width, int $height, [int $x, int $y])

Cut out a rectangular part of the current image with given **width and height**. Define optional **x,y coordinates** to move the top-left corner of the cutout to a certain position.

### Parameters

#### width
Width of the rectangular cutout.

#### height
Height of the rectangular cutout.

#### x (optional)
X-Coordinate of the top-left corner if the rectangular cutout. By default the rectangular part will be centered on the current image.

#### y (optional)
Y-Coordinate of the top-left corner if the rectangular cutout. By default the rectangular part will be centered on the current image.

### Return Values
Instance of `Intervention\Image\Image`

### Examples

```php
// open file a image resource
$img = Image::make('public/foo.jpg');

// crop image
$img->crop(100, 100, 25, 25);
```

### See also

- [resize](https://image.intervention.io/v2/api/resize.md)
- [resizeCanvas](https://image.intervention.io/v2/api/resize-canvas.md)
- [fit](https://image.intervention.io/v2/api/fit.md)
- [trim](https://image.intervention.io/v2/api/trim.md)

---

## Become a Sponsor

### Intervention Image needs your help to keep the project going

Intervention Image is non-commercial, open source licensed and completely free to use. The considerable
effort required to maintain and develop the software is only possible with the financial support
of sponsors. There are two ways in which you can support this project.

- Support via [GitHub Sponsors](https://github.com/sponsors/Intervention)
- Support via [Ko-Fi](https://ko-fi.com/interventionphp)