mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
if the resized and optimized image is larger than original, then keep the original
This commit is contained in:
parent
6b3c8b4bac
commit
8da8dfc543
@ -51,6 +51,13 @@ async function shrinkImage(buffer, originalName) {
|
|||||||
log.error("Failed to optimize image '" + originalName + "\nStack: " + e.stack);
|
log.error("Failed to optimize image '" + originalName + "\nStack: " + e.stack);
|
||||||
finalImageBuffer = resizedImage;
|
finalImageBuffer = resizedImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if resizing & shrinking did not help with size then save the original
|
||||||
|
// (can happen when e.g. resizing PNG into JPEG)
|
||||||
|
if (finalImageBuffer.byteLength >= buffer.byteLength) {
|
||||||
|
finalImageBuffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
return finalImageBuffer;
|
return finalImageBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user