Repository navigation
feat: Make Stored Upload Image Resolution Configurable - #16983
Open
RutgerLubbers wants to merge 2 commits into
Open
RutgerLubbers wants to merge 2 commits into
RutgerLubbers wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Validation currently accepts invalid or ambiguous resize values, and defaulting behavior is placed in the legacy CJS layer.
4 open findings
What changed in this PR
Adds configurable server-side resizing for stored image uploads while preserving the existing high default.
Changes:
- Adds and documents
imageUploadResizeconfiguration. - Propagates resize settings through upload storage handlers.
- Adds schema and passthrough tests.
| File | Description |
|---|---|
packages/data-provider/src/file-config.ts |
Defines the resize configuration schema and type. |
packages/data-provider/specs/config-schemas.spec.ts |
Tests accepted and rejected configurations. |
packages/api/src/storage/types.ts |
Types custom upload resolutions. |
packages/api/src/storage/images.ts |
Accepts custom resolutions in cloud storage. |
packages/api/src/storage/__tests__/images.test.ts |
Tests custom resolution forwarding. |
librechat.example.yaml |
Documents the new setting. |
api/server/services/Files/process.spec.js |
Tests upload-path configuration forwarding. |
api/server/services/Files/process.js |
Passes configured resolution into storage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RutgerLubbers
force-pushed
the
feat/upload-resize-config
branch
from
October 11, 2026 12:21
718ea4c to
d90cbce
Compare
Add fileConfig.imageUploadResize so deployers can pick the resolution applied
when storing image uploads: a named preset ('high' | 'low') or { px } (cap the
longest edge, keeping aspect ratio) / { percentage }. Defaults to 'high', so
existing behavior is unchanged.
processImageFile reads the value off the deployment config (mirroring the
existing draft-image `imageGeneration` consumer) and passes it to the storage
handlers; both Local's uploadLocalImage and the packages/api ImageService
already accept a resolution argument, they just never received one from the
upload path. The imageUploadResizeSchema validates the shape via the config
schema.
Why it matters: providers' image tools work on the stored upload, and
OpenAI-compatible image servers (e.g. local FLUX.2 / Qwen models) commonly size
their edit output to the input's dimensions, so this effectively caps the images
those tools produce - bigger than the built-in 'high' preset when the server can
handle it, smaller when storage or a provider's limits demand it.
Model the custom resize forms as an exclusive union in both the schema and
the storage type, so `{}` and dual-key objects (`px` + `percentage`) are
rejected instead of silently accepted or ignored.
Reject `percentage: 0`, which previously passed validation but produced
zero-sized targets that Sharp rejects at the storage layer.
Keep /api wiring-only per AGENTS.md: `processImageFile` passes
`imageUploadResize` through unchanged when unset, leaving the existing
'high' default at the storage handlers.
RutgerLubbers
force-pushed
the
feat/upload-resize-config
branch
from
October 11, 2026 13:47
d90cbce to
c9bfe54
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Stored image uploads are always resized to the built-in
'high'preset (short side ≤ 768px, long side ≤ 2000px) with no way to change it. Anything that reads the stored upload is capped at that size.This adds
fileConfig.imageUploadResizeto configure the stored-upload resolution:high(default) /low— presets{ px: 2048 }— longest-edge cap, aspect ratio preserved{ percentage: 50 }— scale relative to the originalImplementation
The storage handlers already accept a
resolutionargument defaulting to'high'; the upload path just never passed one.processImageFilenow readsfileConfig.imageUploadResizeand forwards it throughhandleImageUpload, covering every storage strategy (Local, S3, CloudFront, Azure, Firebase).resizeImageBufferalready handles{ px }/{ percentage }, so it is unchanged.imageUploadResizeSchemavalidates the value via the existingconfigSchema;TImageUploadResize/ImageUploadResolutionflow into the storage layer. Default remains'high'(current behavior).Testing
packages/api/src/storage/__tests__/images.test.ts—{ px }resolution reachesresizeImageBuffer.api/server/services/Files/process.spec.js— configuredimageUploadResizeis forwarded tohandleImageUpload; unset defaults to'high'.packages/data-provider/specs/config-schemas.spec.ts— accepts presets and{ px }/{ percentage }; rejects unknown presets, bare objects, andpx: 0.tsc --noEmitclean inpackages/apiandpackages/data-provider; eslint/prettier clean.Compatibility
Optional key; the default reproduces current behavior. Per-endpoint overrides are a possible follow-up.