Image

Actions for handling image objects

Module: implementation.datasources.image



ImageRead

Read image. Subclass of Action. Type of Action[Dict[str, Any], Image.Image]


__init__

Arguments:

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.

  • default_key (str, optional): What key will be used by default. Defaults to "image".


execute

Arguments:

  • input_data (Dict[str, Any]): Expected keys:

    • "path_to_file" (str): Path to image file;

Raises:

  • Exception: If unable to read image.

Returns:




ImageWrite

Write image. Subclass of Action. Type of Action[Dict[str, Any], None]


execute

Arguments:

  • input_data (Dict[str, Any]): Expected keys:

    • "image" (Image.Image): Image;

    • "path_to_file" (str): Path to image file;

Raises:

  • Exception: If unable to write image.




ImageConvertChannels

Convert image channels. Subclass of Action. Type of Action[Image.Image, Image.Image]


__init__

Arguments:

  • channels_mode (Literal["RGB", "RGBA", "L", "P", "PA", "CMYK"], optional): Channels mode to use. Defaults to "RGB".

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.

  • default_key (str, optional): What key will be used by default. Defaults to "image".


execute

Arguments:

Returns:




ImageRotate

Rotate image. Subclass of Action. Type of Action[Image.Image, Image.Image]


__init__

Arguments:

  • angle (float): Rotation angle in degrees.

  • resample (Image.Resampling, optional): An optional resampling filter. This can be one of Resampling.NEAREST (use nearest neighbour), Resampling.BILINEAR (linear interpolation in a 2x2 environment), or Resampling.BICUBIC (cubic spline interpolation in a 4x4 environment). If the image has mode "1" or "P", it is set to Resampling.NEAREST. Defaults to Resampling.NEAREST.

  • expand (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.

  • center (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.

  • translate (Optional[Tuple[float, float]], optional): An optional post-rotate translation (a 2-tuple).

  • fillcolor (Optional[Any], optional): An optional color for area outside the rotated image.

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.

  • default_key (str, optional): What key will be used by default. Defaults to "image".


execute

Arguments:

Returns:




ImageResize

Resize image. Subclass of Action. Type of Action[Image.Image, Image.Image]


__init__

Arguments:

  • width (int): New width in pixels.

  • height (int): New height in pixels.

  • box (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.

  • reducing_gap (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).

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.

  • default_key (str, optional): What key will be used by default. Defaults to "image".


execute

Arguments:

Returns:




ImagePad

Pad image. Subclass of Action. Type of Action[Image.Image, Image.Image]


__init__

Arguments:

  • width (int): New width in pixels.

  • height (int): New height in pixels.

  • method (Image.Resampling, optional): Resampling method to use. Default is Resampling.BICUBIC.

  • centering (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.

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.

  • default_key (str, optional): What key will be used by default. Defaults to "image".


execute

Arguments:

Returns:




ImagePad

Crop image. Subclass of Action. Type of Action[Image.Image, Image.Image]


__init__

Arguments:

  • box (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).

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.

  • default_key (str, optional): What key will be used by default. Defaults to "image".


execute

Arguments:

Returns:



Last updated