Updated on 2026-11-06 GMT+08:00

Images

Images are processed internally using the Pillow library. By obtaining a Python Imaging Library (PIL) image object, you can process images through the PIL. Supported image formats include JPEG and PNG.

Table 1 Properties

Property

Type

Description

filename

str

File name or path of the image (if loaded from a file).

format

str

Image format (e.g. PNG, JPEG).

height

int

Image height in pixels.

width

int

Image width in pixels.

data

bytes

Image data.

Table 2 Methods

Method

Parameter

Return Value

Description

__init__

  • filename: Union[str, os.PathLike] = None
  • data: Union[str, PIL.Image] = None
  • format: Optional[str] = None

None

Constructor: Loads an image from a file (filename) or data (data), supporting bytes or Pillow objects.

to_numpy

-

np.ndarray

Converts the image to a NumPy array (float32).

resize

new_shape: tuple[int, int]

Image

Returns a new resized image based on the specified dimensions.

show

-

None

Displays the image using Pillow's default viewer.

to_thumbnail

size: tuple[int, int] = (100, 100)

Image

Generates a thumbnail with the specified size.

crop

box: tuple[float, float, float, float]

Image

Crops a specified area in an image and returns a new image.

getbands

-

tuple: [str, ...]

Calls Pillow's getbands().

getmode

-

str

Returns the image mode.

to_struct

-

dict

Returns the structured image data.