Skip to main content

ImageResize

Resize the image to either a specific shape or scale.

This module provides a pipeline element to resize the image to a specific shape or scale it and preserve the aspect ratio. This function is DESTRUCTIVE and will modify the image in place. 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:

Scale an image to 640x480:

```yaml
source:
- address: videos/sd_london_station_sd.mp4
type: file
elements:
- name: image-resize
args:
width: 640
height: 480
```

Scale down an image by 50%:

```yaml
source:
- address: videos/sd_london_station_sd.mp4
type: file
elements:
- name: image-resize
args:
scale: 0.5
```

ImageResize Objects

class ImageResize(Element)

Resize the image to either a specific shape or scale it and preserve the aspect ratio.

Attributes:

  • name str - The name of the element.

Examples:

Shape:

```python
ele = ImageResize(width=640, height=480)
```

Scale:

```python
ele = ImageResize(scale=0.5)
```

process

def process(meta: PipelineMetadata)

Process the metadata by resizing the image.

This is the main function for this element. It will process the metadata by resizing the image. This function is DESTRUCTIVE and will overwrite the existing image in the metadata.

Arguments:

  • meta PipelineMetadata - The metadata to process.

Returns:

  • meta PipelineMetadata - The processed metadata.

Examples:

```python
meta = ImageResize(width=640, height=480).process(meta)
```