// Engangsjobb: skapa -s (800px) och -m (1600px) for redan synkade portfolio-bilder. // Kallan ar den befintliga 3000px-filen i repot - ingen ny nedladdning fran Immich. import fs from "node:fs"; import path from "node:path"; import sharp from "sharp"; const DIR = "src/assets/images/portfolio"; const SIZES = [{ suffix: "-s", dim: 800 }, { suffix: "-m", dim: 1600 }]; const QUALITY = 88; const files = fs.readdirSync(DIR).filter( (f) => /^immich-[0-9a-f-]{36}-/i.test(f) && /\.jpg$/i.test(f) && !/-[sm]\.jpg$/i.test(f) ); console.log(`hittade ${files.length} large-bilder`); let skapade = 0, hoppade = 0; for (const f of files) { const src = path.join(DIR, f); const base = src.replace(/\.jpg$/i, ""); for (const { suffix, dim } of SIZES) { const dest = `${base}${suffix}.jpg`; if (fs.existsSync(dest)) { hoppade++; continue; } await sharp(src) .rotate() .resize(dim, dim, { fit: "inside", withoutEnlargement: true }) .withMetadata() .jpeg({ quality: QUALITY }) .toFile(dest); skapade++; } } console.log(`klart: ${skapade} skapade, ${hoppade} fanns redan`);