> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/modularity/image-manipulation/reference/built-in-functions/imagecrop.md).

# ImageCrop

Crops an image to a specified rectangular area. This BIF allows you to select a region of an image to keep, discarding the rest, in BoxLang.

## Syntax

```
ImageCrop(name, x, y, width, height)
```

## Arguments

| Name   | Type    | Required | Description                                                             |
| ------ | ------- | -------- | ----------------------------------------------------------------------- |
| name   | any     | Yes      | The image or the name of a variable referencing an image to operate on. |
| x      | numeric | Yes      | The x coordinate of the upper left corner of the crop area.             |
| y      | numeric | Yes      | The y coordinate of the upper left corner of the crop area.             |
| width  | numeric | Yes      | The width of the crop area.                                             |
| height | numeric | Yes      | The height of the crop area.                                            |

## Returns

* **BoxImage**: The modified BoxImage instance cropped to the specified area.

## Description

`ImageCrop` crops the specified image to a rectangular region, starting at (x, y) and extending to the given width and height. Only the selected area will remain visible after the operation. The image can be passed directly or referenced by variable name.

## Example

```boxlang
// Crop a 100x50 region at position (10, 20)
img = ImageCrop(myImage, 10, 20, 100, 50);
```

## See Also

* ImageResize
* ImageCopy

## Notes

* All arguments are required.
* The image can be passed as a BoxImage object or as a variable name referencing an image.
* The crop region must be within the image boundaries.
* Returns the modified image object for method chaining.
* The cropped image becomes the new image - original content outside the crop area is discarded.
* Coordinates start at (0, 0) in the top-left corner.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/modularity/image-manipulation/reference/built-in-functions/imagecrop.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
