imgutils.data.background

grid_background

imgutils.data.background.grid_background(height, width, step: int | None = None, forecolor: str = 'lightgrey', backcolor: str = 'white')[source]
Overview:

Create an image with black and white squares, which can be used to complement transparent areas of an image with a transparent background.

Parameters:
  • height – Height of image.

  • width – Width of image.

  • step – The step size of the grid in pixels. The default value is None, which means that this function will automatically generate a suitable step value.

  • forecolor – Color of the fore grids.

  • backcolor – Color of the back grids.

Returns:

A RGBA image which contains the grids.

grid_transparent

imgutils.data.background.grid_transparent(image: str | PathLike | bytes | bytearray | BinaryIO | Image, step: int | None = None, forecolor: str = 'lightgrey', backcolor: str = 'white')[source]
Overview:

Add a gridded background to an image with a transparent background.

Parameters:
  • image – Original image.

  • step – The step size of the grid in pixels. The default value is None, which means that this function will automatically generate a suitable step value.

  • forecolor – Color of the fore grids.

  • backcolor – Color of the back grids.

Returns:

A RGB image which contains the grids and the original image.

Note

In this document, grid_transparent() is the default option used to accurately present the state of the generated image, as shown in the following figure

../../_images/grid_transparent.plot.py.svg