fix: resolve typescript compilation error with sharp buffer in thumbnail handler
This commit is contained in:
1 parent
7e85b35486
commit
fe2f82244d
1 file changed
+6
-9
@@ -115,20 +115,17 @@ async function watermarkedThumbnailResponse(thumbnail: ImmichBinary, assetId: st
|
|||||||
const buffer = Buffer.concat(chunks);
|
const buffer = Buffer.concat(chunks);
|
||||||
|
|
||||||
// Skaliere das Bild auf 480px Breite (wie vom User gewünscht)
|
// Skaliere das Bild auf 480px Breite (wie vom User gewünscht)
|
||||||
const targetWidth = 480;
|
// Skaliere das Bild so, dass es in eine 800x800 Box passt (damit Hoch- und Querformat korrekt skaliert werden)
|
||||||
|
const targetSize = 800;
|
||||||
const resizedBuffer = await sharp(buffer)
|
const resizedBuffer = await sharp(buffer)
|
||||||
.resize({ width: targetWidth, withoutEnlargement: true })
|
.resize({ width: targetSize, height: targetSize, fit: "inside", withoutEnlargement: true })
|
||||||
let watermarked = buffer;
|
.toBuffer();
|
||||||
|
|
||||||
|
let watermarked = resizedBuffer;
|
||||||
try {
|
try {
|
||||||
const logoPath = path.join(process.cwd(), "public", "brand", "logo-white.png");
|
const logoPath = path.join(process.cwd(), "public", "brand", "logo-white.png");
|
||||||
const logoBuffer = await fs.readFile(logoPath);
|
const logoBuffer = await fs.readFile(logoPath);
|
||||||
|
|
||||||
// Skaliere das Bild so, dass es in eine 800x800 Box passt (damit Hoch- und Querformat korrekt skaliert werden)
|
|
||||||
const targetSize = 800;
|
|
||||||
const resizedBuffer = await sharp(buffer)
|
|
||||||
.resize({ width: targetSize, height: targetSize, fit: "inside", withoutEnlargement: true })
|
|
||||||
.toBuffer();
|
|
||||||
|
|
||||||
const { width, height } = await sharp(resizedBuffer).metadata();
|
const { width, height } = await sharp(resizedBuffer).metadata();
|
||||||
|
|
||||||
// Berechne Wasserzeichen-Größe (50% der Bildbreite, max 400px)
|
// Berechne Wasserzeichen-Größe (50% der Bildbreite, max 400px)
|
||||||
|
|||||||
Reference in new issue
Block a user