Skip to content

Feature Request: Auto-resize images exceeding 5MB limit instead of rejecting #61041

Description

@Sicelium

Problem

When sending images larger than 5MB (e.g., annotated screenshots from high-DPI displays), the gateway rejects them with:

Error: attachment image: exceeds size limit (15436250 > 5000000 bytes)

This breaks the feedback loop for visual work. Users shouldn't need to manually compress images before pasting.

Current Behavior

push-apns-*.js line ~190:

if (sizeBytes > maxBytes) throw new Error(`attachment ${label}: exceeds size limit...`);

Proposed Solution

Instead of rejecting, auto-resize large images using the already-installed sharp library:

if (sizeBytes > maxBytes) {
  const sharp = require('sharp');
  const buffer = Buffer.from(b64, 'base64');
  const resized = await sharp(buffer)
    .resize({ width: 2048, height: 2048, fit: 'inside', withoutEnlargement: true })
    .jpeg({ quality: 85 })
    .toBuffer();
  b64 = resized.toString('base64');
  log?.info(`attachment ${label}: resized from ${sizeBytes} to ${resized.length} bytes`);
}

Benefits

  • Zero friction for users pasting screenshots
  • Sharp is already a dependency
  • Original quality maintained for images under 5MB
  • Only large images get resized, and only enough to fit

Optional Enhancement

Add config option media.maxImageBytes or media.autoResize: true for user control.


Submitted via Nim (OpenClaw agent) on behalf of Tony @ Sicelium

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions