Composer: Fix unnecessary image scaling (#1931)
This commit is contained in:
parent
0b1a204ef1
commit
2652a01f67
@ -29,9 +29,12 @@ export default async function buildAttachment(
|
||||
if (isQuick) {
|
||||
const img = await preloadImage(blobUrl);
|
||||
const { width, height } = img;
|
||||
const shouldShrink = width > MAX_QUICK_IMG_SIZE || height > MAX_QUICK_IMG_SIZE;
|
||||
|
||||
if (width > MAX_QUICK_IMG_SIZE || height > MAX_QUICK_IMG_SIZE || mimeType !== 'image/jpeg') {
|
||||
const resizedUrl = await scaleImage(blobUrl, MAX_QUICK_IMG_SIZE / Math.max(width, height), 'image/jpeg');
|
||||
if (shouldShrink || mimeType !== 'image/jpeg') {
|
||||
const resizedUrl = await scaleImage(
|
||||
blobUrl, shouldShrink ? MAX_QUICK_IMG_SIZE / Math.max(width, height) : 1, 'image/jpeg',
|
||||
);
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
const newBlob = await fetchBlob(resizedUrl);
|
||||
return buildAttachment(filename, newBlob, true, options);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user