mirror of
https://github.com/zadam/trilium.git
synced 2025-01-16 03:58:53 +08:00
Merge remote-tracking branch 'origin/stable'
# Conflicts: # package-lock.json # package.json # src/services/image.js
This commit is contained in:
commit
28ebca1268
3 changed files with 16 additions and 6 deletions
|
@ -32,6 +32,7 @@ const TPL = `
|
|||
.tree {
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.refresh-search-button {
|
||||
|
|
|
@ -20,8 +20,8 @@ const TPL = `
|
|||
}
|
||||
</style>
|
||||
|
||||
<button class="hide-left-pane-button btn btn-sm icon-button bx bx-chevrons-left" title="Show sidebar"></button>
|
||||
<button class="show-left-pane-button btn btn-sm icon-button bx bx-chevrons-right" title="Hide sidebar"></button>
|
||||
<button class="hide-left-pane-button btn btn-sm icon-button bx bx-chevrons-left" title="Hide sidebar"></button>
|
||||
<button class="show-left-pane-button btn btn-sm icon-button bx bx-chevrons-right" title="Show sidebar"></button>
|
||||
|
||||
<button class="hide-right-pane-button btn btn-sm icon-button bx bx-chevrons-right" title="Hide sidebar"></button>
|
||||
<button class="show-right-pane-button btn btn-sm icon-button bx bx-chevrons-left" title="Show sidebar"></button>
|
||||
|
|
|
@ -20,7 +20,7 @@ async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
|
|||
shrinkImageSwitch = false;
|
||||
}
|
||||
|
||||
const finalImageBuffer = shrinkImageSwitch ? await shrinkImage(uploadBuffer) : uploadBuffer;
|
||||
const finalImageBuffer = shrinkImageSwitch ? await shrinkImage(uploadBuffer, originalName) : uploadBuffer;
|
||||
|
||||
const imageFormat = getImageType(finalImageBuffer);
|
||||
|
||||
|
@ -104,11 +104,20 @@ function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch)
|
|||
};
|
||||
}
|
||||
|
||||
async function shrinkImage(buffer) {
|
||||
async function shrinkImage(buffer, originalName) {
|
||||
const jpegQuality = optionService.getOptionInt('imageJpegQuality');
|
||||
let finalImageBuffer = await resize(buffer, jpegQuality);
|
||||
|
||||
// if resizing & shrinking did not help with size then save the original
|
||||
let finalImageBuffer;
|
||||
try {
|
||||
finalImageBuffer = await resize(buffer, jpegQuality);
|
||||
}
|
||||
catch (e) {
|
||||
log.error("Failed to resize image '" + originalName + "'\nStack: " + e.stack);
|
||||
|
||||
finalImageBuffer = buffer;
|
||||
}
|
||||
|
||||
// if resizing 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;
|
||||
|
|
Loading…
Reference in a new issue