Skip to main content

ImageCrop

Crop the image to a specific x, y, width and height.

This module provides a pipeline element to crop the image to a specific x, y, width and height. This function is DESTRUCTIVE and will modify the image in place. It is not intended to be used after any deep learning model or analytics has been applied. Please note that any image resizing needed for deep learning models are handled under-the-hood and the original image is preserved.

Examples:

REST API:

WIP

Configuration File:

Crop the 640x480 center of a 1920x1080 image:

```yaml
source:
- address: videos/sd_london_station_sd.mp4
type: file
elements:
- name: image-crop
args:
x: 960
y: 540
width: 640
height: 480
```

ImageCrop Objects

class ImageCrop(Element)

Crop the image to a specific x, y, width and height.

Attributes:

  • name str - The name of the element.
  • x int - The x coordinate of the top left corner of the crop.
  • y int - The y coordinate of the top left corner of the crop.
  • width int - The width of the crop.
  • height int - The height of the crop.

Examples:

```python
ele = ImageCrop(x=0, y=0, width=640, height=480)
```

process

def process(meta: PipelineMetadata)

Process the metadata by cropping the image.

This is the main function for this element. It will process the metadata by cropping the image. This function is DESTRUCTIVE and will modify the image in place.

Arguments:

  • meta PipelineMetadata - The metadata to process.

Returns:

  • meta PipelineMetadata - The processed metadata.

Examples:

```python
meta = ImageCrop(x=0, y=0, width=640, height=480).process(meta)
```