Skip to content

testudos.internal.types.image

testudos.internal.types.image

Image helpers for Testudos.

Wraps QImage payloads returned by the backend (captureScreen / captureItem) and provides utilities for saving them to disk and converting to Pillow Image objects for comparison.

CapturedImage Objects

@dataclass
class CapturedImage()

Represents an image captured on the Qt side and sent via RPC.

The backend encodes QImage as JSON with fields:

  • isNull: bool
  • width: int
  • height: int
  • format: int (Qt::ImageFormat enum value)
  • data: base64-encoded PNG bytes (only when not null)

from_rpc_result

@classmethod
def from_rpc_result(cls, payload: dict[str, Any]) -> "CapturedImage"

Create CapturedImage from RPC result produced by serializeQImage().

Arguments:

  • payload - Dict returned in “result” from captureScreen/captureItem.

Returns:

CapturedImage instance (is_null will be True if image is null).

save

def save(path: str) -> None

Save PNG bytes to a file.

Arguments:

  • path - Destination file path.

to_pillow

def to_pillow()

Convert the image to a Pillow Image instance.

Returns:

PIL.Image.Image instance.

Raises:

  • ImportError - If Pillow is not installed.
  • ValueError - If the image is null.