mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 19:51:57 +08:00
if the resized and optimized image is larger than original, then keep the original
This commit is contained in:
parent
6b3c8b4bac
commit
8da8dfc543
1 changed files with 7 additions and 0 deletions
|
@ -51,6 +51,13 @@ async function shrinkImage(buffer, originalName) {
|
|||
log.error("Failed to optimize image '" + originalName + "\nStack: " + e.stack);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue