This commit is contained in:
seb
2026-09-18 07:13:56 +02:00
parent 9e9d3154ca
commit bac6f2a801
3 changed files with 107 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
import { createHash } from 'node:crypto';
import sharp from 'sharp';
import generateDocumentThumb from '../../util/generateDocumentThumb.js';
import {
CREATE_FILE,
CREATE_ATTACHMENT,
@@ -142,19 +143,10 @@ export default function add(pool) {
}
if (!thumbavif) {
try {
const thumbResult = await sharp(content)
.resize(200, 200, { fit: 'inside', withoutEnlargement: true })
.avif({ effort: 4 })
.toBuffer({ resolveWithObject: true });
thumbavif = thumbResult.data;
thumbx = thumbResult.info.width;
thumby = thumbResult.info.height;
} catch {
thumbavif = null;
thumbx = null;
thumby = null;
}
const generated = await generateDocumentThumb(content, mimetype);
thumbavif = generated.thumbavif;
thumbx = generated.thumbx;
thumby = generated.thumby;
}
const { companyId } = await access(googleAuthId);