Skip to content

bug: Downscaling re-encodes PNG losslessly, so large PNGs still exceed the size limit #262

Description

@monon999

Version: 2.0.23

Describe the Bug

In imageDownscale.ts, only JPEG input is re-encoded as JPEG (quality 0.92); PNG and WebP are written back out as PNG to stay lossless.

With the default "Max image size" of 2048 px, a 5120x5120 PNG is correctly downscaled, but the resulting PNG is still over 10 MB, so it is rejected by the size check with image.png exceeds the 10MB limit.

Since the vision tower resamples to a fixed resolution anyway, keeping a lossless PNG doesn't buy any accuracy — it only inflates the base64 payload and the context. Encoding to JPEG when the image has no alpha channel, or producing both and keeping the smaller one, would avoid this.

Steps to Reproduce

  1. Keep "Max image size" at the default 2048 px.
  2. Prepare a detailed 5120x5120 PNG (mine is 23.3 MB).
  3. Copy it to the clipboard and paste it into the chat input.
  4. It is rejected with "image.png exceeds the 10MB limit", even though it was downscaled to 2048 px first.

Screenshots / Logs

Image

Operating System

  • MacOS
  • Windows
  • Linux

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions