mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-02 22:21:41 +08:00
Merge pull request #647 from TriliumNext/renovate/jimp-1.x
fix(deps): update dependency jimp to v1
This commit is contained in:
commit
d204aca228
1235
package-lock.json
generated
1235
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -99,7 +99,7 @@
|
|||||||
"ini": "5.0.0",
|
"ini": "5.0.0",
|
||||||
"is-animated": "2.0.2",
|
"is-animated": "2.0.2",
|
||||||
"is-svg": "4.4.0",
|
"is-svg": "4.4.0",
|
||||||
"jimp": "0.22.12",
|
"jimp": "1.6.0",
|
||||||
"joplin-turndown-plugin-gfm": "1.0.12",
|
"joplin-turndown-plugin-gfm": "1.0.12",
|
||||||
"jquery": "3.7.1",
|
"jquery": "3.7.1",
|
||||||
"jquery-hotkeys": "0.2.2",
|
"jquery-hotkeys": "0.2.2",
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import protectedSessionService from "./protected_session.js";
|
|||||||
import noteService from "./notes.js";
|
import noteService from "./notes.js";
|
||||||
import optionService from "./options.js";
|
import optionService from "./options.js";
|
||||||
import sql from "./sql.js";
|
import sql from "./sql.js";
|
||||||
import jimp from "jimp";
|
import { Jimp } from "jimp";
|
||||||
import imageType from "image-type";
|
import imageType from "image-type";
|
||||||
import sanitizeFilename from "sanitize-filename";
|
import sanitizeFilename from "sanitize-filename";
|
||||||
import isSvg from "is-svg";
|
import isSvg from "is-svg";
|
||||||
@ -212,21 +212,19 @@ async function resize(buffer: Buffer, quality: number) {
|
|||||||
|
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
|
|
||||||
const image = await jimp.read(buffer);
|
const image = await Jimp.read(buffer);
|
||||||
|
|
||||||
if (image.bitmap.width > image.bitmap.height && image.bitmap.width > imageMaxWidthHeight) {
|
if (image.bitmap.width > image.bitmap.height && image.bitmap.width > imageMaxWidthHeight) {
|
||||||
image.resize(imageMaxWidthHeight, jimp.AUTO);
|
image.resize({ w: imageMaxWidthHeight });
|
||||||
}
|
}
|
||||||
else if (image.bitmap.height > imageMaxWidthHeight) {
|
else if (image.bitmap.height > imageMaxWidthHeight) {
|
||||||
image.resize(jimp.AUTO, imageMaxWidthHeight);
|
image.resize({ h: imageMaxWidthHeight });
|
||||||
}
|
}
|
||||||
|
|
||||||
image.quality(quality);
|
|
||||||
|
|
||||||
// when converting PNG to JPG, we lose the alpha channel, this is replaced by white to match Trilium white background
|
// when converting PNG to JPG, we lose the alpha channel, this is replaced by white to match Trilium white background
|
||||||
image.background(0xFFFFFFFF);
|
image.background = 0xFFFFFFFF;
|
||||||
|
|
||||||
const resultBuffer = await image.getBufferAsync(jimp.MIME_JPEG);
|
const resultBuffer = await image.getBuffer("image/jpeg", { quality });
|
||||||
|
|
||||||
log.info(`Resizing image of ${resultBuffer.byteLength} took ${Date.now() - start}ms`);
|
log.info(`Resizing image of ${resultBuffer.byteLength} took ${Date.now() - start}ms`);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user