mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
fix: correct client image resize threshold handling
Add configurable minFileSizeKB support to clientImageResize and pass it through to shouldResizeImage so typical user photos are eligible for resize. Also document minFileSizeKB in librechat.example.yaml with a practical default. Made-with: Cursor
This commit is contained in:
parent
f277b32030
commit
5996880be1
3 changed files with 8 additions and 3 deletions
|
|
@ -25,8 +25,10 @@ export const useClientResize = () => {
|
|||
maxWidth: 1900,
|
||||
maxHeight: 1900,
|
||||
quality: 0.92,
|
||||
minFileSizeKB: 1024,
|
||||
};
|
||||
const isEnabled = config?.enabled ?? false;
|
||||
const minFileSizeBytes = (config?.minFileSizeKB ?? 1024) * 1024;
|
||||
|
||||
/**
|
||||
* Resizes an image if client-side resizing is enabled and supported
|
||||
|
|
@ -50,8 +52,8 @@ export const useClientResize = () => {
|
|||
return { file, resized: false };
|
||||
}
|
||||
|
||||
// Return original file if it doesn't need resizing
|
||||
if (!shouldResizeImage(file)) {
|
||||
// Return original file if it's below the minimum size threshold
|
||||
if (!shouldResizeImage(file, minFileSizeBytes)) {
|
||||
return { file, resized: false };
|
||||
}
|
||||
|
||||
|
|
@ -70,7 +72,7 @@ export const useClientResize = () => {
|
|||
return { file, resized: false };
|
||||
}
|
||||
},
|
||||
[isEnabled, config],
|
||||
[isEnabled, config, minFileSizeBytes],
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -570,6 +570,7 @@ endpoints:
|
|||
# maxWidth: 1900 # Maximum width for resized images (default: 1900)
|
||||
# maxHeight: 1900 # Maximum height for resized images (default: 1900)
|
||||
# quality: 0.92 # JPEG quality for compression (0.0-1.0, default: 0.92)
|
||||
# minFileSizeKB: 1024 # Skip resizing files smaller than this size in KB (default: 1024)
|
||||
# # See the Custom Configuration Guide for more information on Assistants Config:
|
||||
# # https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/assistants_endpoint
|
||||
|
||||
|
|
|
|||
|
|
@ -427,6 +427,7 @@ export const fileConfig = {
|
|||
maxWidth: 1900,
|
||||
maxHeight: 1900,
|
||||
quality: 0.92,
|
||||
minFileSizeKB: 1024,
|
||||
},
|
||||
ocr: {
|
||||
supportedMimeTypes: defaultOCRMimeTypes,
|
||||
|
|
@ -484,6 +485,7 @@ export const fileConfigSchema = z.object({
|
|||
maxWidth: z.number().min(0).optional(),
|
||||
maxHeight: z.number().min(0).optional(),
|
||||
quality: z.number().min(0).max(1).optional(),
|
||||
minFileSizeKB: z.number().min(0).optional(),
|
||||
})
|
||||
.optional(),
|
||||
ocr: z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue