mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 03:46:37 +01:00
Improve image compression (#2369)
* added options * added checkbox handling to import into note * added image compression option respecting
This commit is contained in:
@@ -14,6 +14,7 @@ const isSvg = require('is-svg');
|
||||
const isAnimated = require('is-animated');
|
||||
|
||||
async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
|
||||
const compressImages = optionService.getOptionBool("compressImages");
|
||||
const origImageFormat = getImageType(uploadBuffer);
|
||||
|
||||
if (origImageFormat && ["webp", "svg", "gif"].includes(origImageFormat.ext)) {
|
||||
@@ -25,7 +26,7 @@ async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
|
||||
shrinkImageSwitch = false;
|
||||
}
|
||||
|
||||
const finalImageBuffer = shrinkImageSwitch ? await shrinkImage(uploadBuffer, originalName) : uploadBuffer;
|
||||
const finalImageBuffer = (compressImages && shrinkImageSwitch) ? await shrinkImage(uploadBuffer, originalName) : uploadBuffer;
|
||||
|
||||
const imageFormat = getImageType(finalImageBuffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user