fix: address open triage issues (#21,#26,#45,#46,#47,#30-33)
- #45: re-read local folder when recursive checkbox toggles - #47: clear Identify crop spinner when image is already cached - #46: search selected people by person_ids; AND for "First Last" - #21: enqueue network import without blocking API walk - #26: serve resized grid thumbnails for photos - #30/#31/#33: re-enable small-face filters in auto-match
This commit is contained in:
@@ -260,6 +260,38 @@ export async function GET(
|
||||
},
|
||||
});
|
||||
|
||||
// Grid thumbnails: resize photos (videos handled above) — #26
|
||||
if (thumbnail && sharp) {
|
||||
try {
|
||||
let pipeline = sharp(imageBuffer).rotate().resize({
|
||||
width: 480,
|
||||
height: 480,
|
||||
fit: 'inside',
|
||||
withoutEnlargement: true,
|
||||
});
|
||||
if (watermark) {
|
||||
const metadata = await pipeline.metadata();
|
||||
const baseWidth = metadata.width ?? 480;
|
||||
const baseHeight = metadata.height ?? 480;
|
||||
const overlayBuffer = await getWatermarkOverlay(baseWidth, baseHeight);
|
||||
pipeline = sharp(imageBuffer)
|
||||
.rotate()
|
||||
.resize({ width: 480, height: 480, fit: 'inside', withoutEnlargement: true })
|
||||
.composite([{ input: overlayBuffer, gravity: 'center', blend: 'hard-light' }]);
|
||||
}
|
||||
const result = await pipeline.jpeg({ quality: 75 }).toBuffer();
|
||||
return new NextResponse(result as unknown as BodyInit, {
|
||||
headers: {
|
||||
'Content-Type': 'image/jpeg',
|
||||
'Cache-Control': 'public, max-age=86400',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error generating image thumbnail:', error);
|
||||
// fall through to original / watermarked full image
|
||||
}
|
||||
}
|
||||
|
||||
if (!watermark) {
|
||||
return createOriginalResponse();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user