Skip to main content

Tools for coordinate mapping and screenshot transformations across screen resolutions for GUI agents

Project description

gui-agent-screenshot-tools

Tools for coordinate mapping and screenshot transformations across screen resolutions for GUI agents.

When a GUI agent takes a screenshot at one resolution and needs to map coordinates to a different resolution (e.g. the actual display), this library handles the math — including letterboxing and stretch transforms.

Installation

pip install gui-agent-screenshot-tools

Usage

from gui_agent_screenshot_tools import Space, Coordinate, Screenshot, ResizeMode

# Define source and target screen spaces
source = Space(width=1920, height=1080)
target = Space(width=1280, height=720)

# Map a coordinate between spaces
coord = Coordinate(x=960, y=540, space=source)
mapped = coord.to_space(target)
print(mapped.x, mapped.y)  # 640, 360

# Resize a screenshot with letterboxing
from PIL import Image

img = Image.new("RGB", (1920, 1080), color=(255, 0, 0))
screenshot = Screenshot.from_image(img)
resized = screenshot.resize(target, ResizeMode.LETTERBOX)

# Map coordinates back through the resize metadata
coord_in_resized = Coordinate(x=640, y=360, space=target)
original = coord_in_resized.to_space(source, resized.resize_metadata)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gui_agent_screenshot_tools-0.1.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gui_agent_screenshot_tools-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file gui_agent_screenshot_tools-0.1.0.tar.gz.

File metadata

File hashes

Hashes for gui_agent_screenshot_tools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 45680e75dcf7d21b4dff80dca2017f459dfc4867f061ab72ef634bc29a7314c8
MD5 f5fcc53831cd9632ea6dced8134802e7
BLAKE2b-256 72f72177be11e4e26915f708dd3b5305d1d871103ab8382cdb2e51f61094645f

See more details on using hashes here.

File details

Details for the file gui_agent_screenshot_tools-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gui_agent_screenshot_tools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 201a72140dba1aa320ac07d5430e2610c6230e9fb2ac0d5f4c69a04a39ad4fd1
MD5 ba490286ab3f2b18a766d60e7df42f30
BLAKE2b-256 625c69b57c56555ae427330d50eb351b26aa7b671c2d2250df959e118379a9ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page