Skip to content

feat: add configurable image downscaling before LLM upload#11913

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/image-downscaling-11912
Draft

feat: add configurable image downscaling before LLM upload#11913
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/image-downscaling-11912

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 12, 2026

This PR attempts to address Issue #11912. It adds configurable image downscaling before images are sent to the LLM, reducing token usage for high-resolution screenshots.

Changes

  • New dependency: sharp for high-performance image processing
  • New settings: maxImageDimension (0 = disabled, default) and imageDownscaleQuality (1-100, default 85)
  • New utility: src/integrations/misc/resize-image.ts -- uses sharp for proportional downscaling preserving aspect ratio
  • Integration: Resizing applied in all image entry points:
    • selectImages() (file picker)
    • readImageAsDataUrlWithBuffer() / processImageFile() (read_file tool)
    • resolveImageMentions() (@-mention image references)
  • Settings UI: New controls in Context Management settings tab
  • Tests: 10 tests for the resize utility, plus updated existing tests

Design decisions

  • Downscaling is disabled by default (opt-in) per issue discussion
  • Uses sharp as recommended by the issue author
  • Only downscales, never upscales
  • Preserves aspect ratio
  • Supports PNG, JPEG, and WebP formats for resizing
  • Unsupported formats (GIF, SVG, etc.) pass through unchanged

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Adds a new image downscaling feature that resizes images before sending
them to the LLM, reducing token usage for high-resolution screenshots.

Changes:
- Add sharp dependency for image processing
- New settings: maxImageDimension (0=disabled) and imageDownscaleQuality (1-100)
- New resize-image.ts utility using sharp for proportional downscaling
- Integrate resizing into all image entry points: selectImages,
  readImageAsDataUrlWithBuffer, processImageFile, resolveImageMentions
- Add settings UI controls in Context Management settings tab
- Add English translation strings for the new settings
- Downscaling disabled by default (opt-in)

Closes #11912
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