Portfolio sync: a photo that fails no longer stops the others; sharp accepts pixel-shift and 15000 px squares

Seen on the first run on Cleura 2026-11-06: 13 photos tagged since 2026-09-29 were never synced. portfolio-sync.mjs
sets exit code 1 when one photo fails (DSC00342_PSMS16-square.jpg: "Input image exceeds pixel limit", sharp's default
268 MP) and set -e then stopped before commit/push - on Nurem as well. Now the photos that worked are committed and
built, the run still ends with exit 1 so systemd shows it, and sharp's limit is 1 000 MP (JPEGs shrink while decoding;
the container gets 3 GB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Olofsson
2026-11-06 05:18:14 +01:00
co-authored by Claude Opus 5.5
parent 8c9afb65c3
commit 24a59c6e93
2 changed files with 12 additions and 3 deletions
+3 -1
View File
@@ -77,7 +77,9 @@ function destName(asset) {
async function downloadAndResize(asset, destPath) {
const res = await api("GET", `/assets/${asset.id}/original`);
const buf = Buffer.from(await res.arrayBuffer());
await sharp(buf)
// Pixel shift and the 15000 px Instagram squares can exceed sharp's default limit (268 MP). JPEGs are shrunk while
// they are decoded, so memory stays low; the sync container still has a memory cap.
await sharp(buf, { limitInputPixels: 1_000_000_000 })
.rotate() // respektera EXIF-orientering
.resize(MAX_DIM, MAX_DIM, { fit: "inside", withoutEnlargement: true })
.withMetadata() // BEVARA EXIF (kritiskt för portfolions datum/kamera)