Skip to content

perf(screenshot): return JPEG and drop the byte cap - #72

Open
hyprcat wants to merge 1 commit into
iFurySt:mainfrom
hyprcat:feat/screenshot-jpeg
Open

hyprcat wants to merge 1 commit into
iFurySt:mainfrom
hyprcat:feat/screenshot-jpeg

Conversation

@hyprcat

@hyprcat hyprcat commented Sep 15, 2026

Copy link
Copy Markdown

What

Window screenshots are returned as JPEG (quality 0.8, longest side 1280) instead of PNG, and the 900 KB byte cap is removed along with the shrink loop that served it.

Why

A model prices an image by its pixel size, not its bytes. The byte cap bought nothing on the model side — it spent local time resizing and re-encoding in a loop, and when a complex page would not fit under 900 KB it gave up pixel size to reach the byte target. That is the one dimension the model actually reads.

With JPEG the same screen is a fraction of the bytes, text stays readable, and pixel size is decided solely by the longest-side cap.

Public API change

OpenComputerUseKit renames follow the behaviour, since a field called screenshotPNGData holding JPEG bytes misleads every later caller:

before after
boundedScreenshotPNGData boundedScreenshotData
ToolResultContentItem.pngImage jpegImage (mimeType image/jpeg)
AccessibilitySnapshot.screenshotPNGData screenshotData

screenshotResultMaxPNGBytes and screenshotResultMinScale are gone.

Verification

  • swift build clean
  • swift test --filter "OpenComputerUseKitTests.OpenComputerUseKitTests" — 163 tests, 0 failures
  • The two size tests now also assert the output really is a JPEG (FF D8 FF)
  • make check-docs passes

Docs, release note and history updated in the same change.

A model prices an image by its pixel size, not its bytes, so the 900 KB PNG
cap bought nothing on the model side: it spent local time resizing and
re-encoding in a loop, and when a complex page would not fit it gave up pixel
size to reach the byte target — the one dimension the model actually reads.

The window picture is now JPEG at quality 0.8 with its longest side capped at
1280, resized once. `screenshotResultMaxPNGBytes` and `screenshotResultMinScale`
are gone with the loop that served them.

Names follow the behaviour, since a field called `screenshotPNGData` holding
JPEG bytes misleads every later caller: `boundedScreenshotPNGData` ->
`boundedScreenshotData`, `ToolResultContentItem.pngImage` -> `jpegImage`
(mimeType `image/jpeg`), `AccessibilitySnapshot.screenshotPNGData` ->
`screenshotData`. This is a public API change in `OpenComputerUseKit`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant