mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 21:35:19 +00:00
compressImage: preserve image type
Previously always exported as PNG, causing JPEG images to balloon 3-10x in size with considerable implications for front-end performance (UI gets sluggish e.g. https://github.com/open-webui/open-webui/discussions/11941)
This commit is contained in:
parent
7a83e7dfa3
commit
fe192eb738
1 changed files with 2 additions and 1 deletions
|
|
@ -348,7 +348,8 @@ export const compressImage = async (imageUrl, maxWidth, maxHeight) => {
|
||||||
context.drawImage(img, 0, 0, width, height);
|
context.drawImage(img, 0, 0, width, height);
|
||||||
|
|
||||||
// Get compressed image URL
|
// Get compressed image URL
|
||||||
const compressedUrl = canvas.toDataURL();
|
const mimeType = imageUrl.match(/^data:([^;]+);/)?.[1];
|
||||||
|
const compressedUrl = canvas.toDataURL(mimeType);
|
||||||
resolve(compressedUrl);
|
resolve(compressedUrl);
|
||||||
};
|
};
|
||||||
img.onerror = (error) => reject(error);
|
img.onerror = (error) => reject(error);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue