feat: Optimize and parallel image processing

This commit is contained in:
Maksim Eltyshev
2025-12-19 19:11:02 +01:00
parent fb5d5233bf
commit 208e61a272
8 changed files with 178 additions and 115 deletions

View File

@@ -162,23 +162,22 @@ module.exports = {
const fileManager = sails.hooks['file-manager'].getInstance();
const { width, height } = metadata;
try {
const buffer = await image
.resize(
32,
32,
width < 32 || height < 32
? {
kernel: sharp.kernel.nearest,
}
: undefined,
)
.png()
.toBuffer();
image = image
.resize(
32,
32,
width < 32 || height < 32
? {
kernel: sharp.kernel.nearest,
}
: undefined,
)
.png();
try {
await fileManager.save(
`${sails.config.custom.faviconsPathSegment}/${hostname}.png`,
buffer,
image,
'image/png',
);
} catch (error) {