> For the complete documentation index, see [llms.txt](https://utca.knowledgator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://utca.knowledgator.com/datasources/image.md).

# Image

Actions for handling image objects

## Module: [implementation](/framework-structure.md#implementation).datasources.image

***

***

## <mark style="color:green;">ImageRead</mark>

Read image. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[Dict\[str, Any],** [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.
* <mark style="color:orange;">**default\_key**</mark>**&#x20;(str, optional):** What key will be used by default. Defaults to "**image".**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):**\
  Expected keys:&#x20;
  * <mark style="color:red;">**"path\_to\_file"**</mark>**&#x20;(str):** Path to image file;

#### Raises:

* **Exception:** If unable to read image.

#### Returns:

* [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**:** Image.

***

***

***

## <mark style="color:green;">ImageWrite</mark>

Write image. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[Dict\[str, Any], None]**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"image"**</mark>**&#x20;(**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**):** Image;
  * <mark style="color:red;">**"path\_to\_file"**</mark>**&#x20;(str):** Path to image file;

#### Raises:

* **Exception:** If unable to write image.

***

***

***

## <mark style="color:green;">ImageConvertChannels</mark>

Convert image channels. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**,** [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**channels\_mode**</mark>**&#x20;(Literal\["RGB", "RGBA", "L", "P", "PA", "CMYK"], optional):** Channels mode to use. Defaults to "RGB".
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.
* <mark style="color:orange;">**default\_key**</mark>**&#x20;(str, optional):** What key will be used by default. Defaults to "**image".**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**):** Image.

#### Returns:

* [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**:** Coverted image.

***

***

***

## <mark style="color:green;">ImageRotate</mark>

Rotate image. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**,** [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**angle**</mark>**&#x20;(float):** Rotation angle in degrees.
* <mark style="color:orange;">**resample**</mark>**&#x20;(**[**Image.Resampling**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#filters)**, optional):** An optional resampling filter. This can be one of [**Resampling.NEAREST**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.NEAREST) (use nearest neighbour), Resampling.BILINEAR (linear interpolation in a 2x2 environment), or [**Resampling.BICUBIC** ](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.BICUBIC)(cubic spline interpolation in a 4x4 environment). If the image has mode "1" or "P", it is set to [**Resampling.NEAREST**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.NEAREST). Defaults to [**Resampling.NEAREST**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.NEAREST).
* <mark style="color:orange;">**expand**</mark>**&#x20;(bool, optional):** Optional expansion flag. If true, expands the output image to make it large enough to hold the entire rotated image. If false, make the output image the same size as the input image. Defaults to False.\
  Note that the expand flag assumes rotation around the center and no translation.
* <mark style="color:orange;">**center**</mark>**&#x20;(Optional\[Tuple\[float, float]], optional):** Optional center of rotation (a 2-tuple). Origin is the upper left corner. Default is the center of the image.
* <mark style="color:orange;">**translate**</mark>**&#x20;(Optional\[Tuple\[float, float]], optional):** An optional post-rotate translation (a 2-tuple).
* <mark style="color:orange;">**fillcolor**</mark>**&#x20;(Optional\[Any], optional):** An optional color for area outside the rotated image.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.
* <mark style="color:orange;">**default\_key**</mark>**&#x20;(str, optional):** What key will be used by default. Defaults to "**image".**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**):** Image.

#### Returns:

* [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**:** Rotated image.

***

***

***

## <mark style="color:green;">ImageResize</mark>

Resize image. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**,** [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**width**</mark>**&#x20;(int):** New width in pixels.
* <mark style="color:orange;">**height**</mark>**&#x20;(int):** New height in pixels.
* <mark style="color:orange;">**resample**</mark>**&#x20;(Optional\[**[**Image.Resampling**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#filters)**], optional):** An optional resampling filter. This can be one of [**Resampling.NEAREST**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.NEAREST), [**Resampling.BOX**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.BOX), [**Resampling.BILINEAR**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.BILINEAR), [**Resampling.HAMMING**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.HAMMING), [**Resampling.BICUBIC**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.BICUBIC) or [**Resampling.LANCZOS**](broken://spaces/vtbRPBMjxq6C5yi0g6mk/pages/596VFj3kGf48zM8sqlVp). If the image has mode "1" or "P", it is always set to [**Resampling.NEAREST**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.NEAREST). If the image mode specifies a number of bits, such as "I;16", then the default filter is [**Resampling.NEAREST**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.NEAREST). Otherwise, the default filter is [**Resampling.BICUBIC**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.BICUBIC). Defaults to None.
* <mark style="color:orange;">**box**</mark>**&#x20;(Optional\[Tuple\[float, float, float, float]], optional):** An optional 4-tuple of floats providing the source image region to be scaled. The values must be within (0, 0, width, height) rectangle. If None, the entire source is used. Defaults to None.
* <mark style="color:orange;">**reducing\_gap**</mark>**&#x20;(Optional\[float], optional):** Apply optimization by resizing the image in two steps. First, reducing the image by integer times using \~PIL.Image.Image.reduce. Second, resizing using regular resampling. The last step changes size no less than by reducing\_gap times. reducing\_gap may be None (no first step is performed) or should be greater than 1.0. The bigger reducing\_gap, the closer the result to the fair resampling. The smaller reducing\_gap, the faster resizing. With reducing\_gap greater or equal to 3.0, the result is indistinguishable from fair resampling in most cases. Defaults to None (no optimization).
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.
* <mark style="color:orange;">**default\_key**</mark>**&#x20;(str, optional):** What key will be used by default. Defaults to "**image".**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**):** Image.

#### Returns:

* [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**:** Resized image.

***

***

***

## <mark style="color:green;">ImagePad</mark>

Pad image. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**,** [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**width**</mark>**&#x20;(int):** New width in pixels.
* <mark style="color:orange;">**height**</mark>**&#x20;(int):** New height in pixels.
* <mark style="color:orange;">**method**</mark>**&#x20;(**[**Image.Resampling**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#filters)**, optional):** Resampling method to use. Default is [**Resampling.BICUBIC**](https://pillow.readthedocs.io/en/stable/handbook/concepts.html#PIL.Image.Resampling.BICUBIC).
* <mark style="color:orange;">**centering**</mark>**&#x20;(Tuple\[float, float], optional)**: Control the position of the original image within the padded version. (0.5, 0.5) will keep the image centered (0, 0) will keep the image aligned to the top left (1, 1) will keep the image aligned to the bottom right.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.
* <mark style="color:orange;">**default\_key**</mark>**&#x20;(str, optional):** What key will be used by default. Defaults to "**image".**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**):** Image.

#### Returns:

* [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**:** Resized image.

***

***

***

## <mark style="color:green;">ImagePad</mark>

Crop image. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**,** [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**box**</mark>**&#x20;(Tuple\[int, int, int, int]):** Bbox for crop. x0, y0, x1, y1, where x0, y0 - left top corner, x1, y1 - right bottom corner (relative in pixels).
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.
* <mark style="color:orange;">**default\_key**</mark>**&#x20;(str, optional):** What key will be used by default. Defaults to "**image".**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(**[**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**):** Image.

#### Returns:

* [**Image.Image**](https://pillow.readthedocs.io/en/stable/reference/Image.html#the-image-class)**:** Croped image.

***

***
