gui-agent-screenshot-tools
Coordinate, bounding-box, and screenshot resize utilities for GUI agents.
This library helps you map detections between:
- original screenshot space
- resized screenshot space (letterbox or stretch)
- physical screen space (with optional window offsets)
Installation
pip install gui-agent-screenshot-tools
Quick Start
from gui_agent_screenshot_tools import Coordinate, Space
source = Space(width=1920, height=1080)
target = Space(width=1280, height=720)
coord = Coordinate(x=960, y=540, space=source)
mapped = coord.to_space(target)
print(mapped.x, mapped.y) # 640 360
Directional APIs
Use directional methods when you have resize metadata:
to_source_space(...): resized -> originalto_target_space(...): original -> resized
Compatibility aliases are still available:
Coordinate.to_space(..., resize_metadata=...)ResizeMetadata.transform_coordinate(...)ResizeMetadata.forward_transform_coordinate(...)
Workflow 1: Detection In Resized Image -> Original Coordinates
from PIL import Image
from gui_agent_screenshot_tools import Coordinate, ResizeMode, Screenshot, Space
img = Image.new("RGB", (1920, 1080), color=(255, 0, 0))
original = Screenshot.from_image(img)
resized = original.resize(Space(width=1024, height=1024), ResizeMode.LETTERBOX)
model_point = Coordinate(x=512, y=512, space=resized.space)
# New helper API
point_in_original = resized.map_coord_to_original(model_point)
print(point_in_original.x, point_in_original.y) # 960 540
Workflow 2: Window-Local BBox -> Screen Coordinates
from PIL import Image
from gui_agent_screenshot_tools import BBox, ResizeMode, Screenshot, Space
screen = Space(width=2560, height=1440)
window = BBox(x=50, y=100, width=1920, height=1080, space=screen)
# Screenshot is of the window content only
img = Image.new("RGB", (1920, 1080), color=(80, 120, 180))
original = Screenshot.from_image(img)
resized = original.resize(Space(width=1024, height=1024), ResizeMode.LETTERBOX)
# Model output in resized screenshot space
model_bbox = BBox(x=100, y=200, width=300, height=150, space=resized.space)
# One call: resized -> original -> screen (via window offset)
screen_bbox = resized.map_bbox_to_original(model_bbox, offset=window)
print(screen_bbox.x, screen_bbox.y, screen_bbox.width, screen_bbox.height)
# 238 100 561 236
Common Mistakes
- Using a coordinate with the wrong
spacefor the metadata direction. Example:to_source_spaceexpects coordinates inmetadata.target_space. - Calling screenshot remap helpers before
resize(...).map_coord_*andmap_bbox_*requireresize_metadata. - Passing an
offsetbbox whoseoffset.as_spacedoes not match the post-transform local space. - Passing a raw string mode to
resize. UseResizeMode.LETTERBOXorResizeMode.STRETCH.
Development
uv run --extra dev python -m pytest -q
License
MIT
Metadata
Release files for gui-agent-screenshot-tools 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gui_agent_screenshot_tools-1.0.0.tar.gz | 44.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gui_agent_screenshot_tools-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.0 kB
Release files / gui_agent_screenshot_tools-1.0.0.tar.gz
| Download URL | gui_agent_screenshot_tools-1.0.0.tar.gz |
|---|---|
| Size | 44.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bdd96f5f705ce9045ac53ec25c309c66bf5d55c5eaa0363752e9d0b7e7c9e55
|
|
BLAKE2b-256 checksum How to use checksums |
96ac36a2ef572287b4833c5abb2e9c7cdb765fd50cad556a413e92801e43e366
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Release files / gui_agent_screenshot_tools-1.0.0-py3-none-any.whl
| Download URL | gui_agent_screenshot_tools-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e61f16a8d5be3e52cd3558cfb748d25c6cd449fd909e570c33f2258da3d8600
|
|
BLAKE2b-256 checksum How to use checksums |
daae445f891541f54453ffea4ea884dfab6801584460a7bb65a685ec9c3fd4ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.2
|
Security for gui-agent-screenshot-tools 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.