Merge pull request #18506 from duncansmart/patch-1

perf: compressImage - preserve image type
This commit is contained in:
Tim Baek 2025-10-22 16:46:15 -04:00 committed by GitHub
commit 92f359fb9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -348,7 +348,8 @@ export const compressImage = async (imageUrl, maxWidth, maxHeight) => {
context.drawImage(img, 0, 0, width, height);
// Get compressed image URL
const compressedUrl = canvas.toDataURL();
const mimeType = imageUrl.match(/^data:([^;]+);/)?.[1];
const compressedUrl = canvas.toDataURL(mimeType);
resolve(compressedUrl);
};
img.onerror = (error) => reject(error);