Web app (browse, search, dashboard, custom fields, family read-only links), Android capture app with offline upload queue and QR pairing, and an MCP server so an AI subscription can identify, value and list items.
39 lines
2.0 KiB
JavaScript
39 lines
2.0 KiB
JavaScript
// Renders the logo into web favicons and Android launcher icons.
|
|
// Usage: node scripts/render-icons.js (from the server/ folder)
|
|
import sharp from 'sharp';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
const brand = path.join(root, 'branding');
|
|
const web = path.join(root, 'server', 'public', 'icons');
|
|
const res = path.join(root, 'android', 'app', 'src', 'main', 'res');
|
|
const logo = path.join(brand, 'logo.svg');
|
|
const mark = path.join(brand, 'mark.svg');
|
|
|
|
fs.mkdirSync(web, { recursive: true });
|
|
fs.copyFileSync(logo, path.join(web, 'logo.svg'));
|
|
fs.copyFileSync(logo, path.join(web, 'favicon.svg'));
|
|
const png = (src, size, out) => sharp(src, { density: 400 }).resize(size, size).png().toFile(out);
|
|
await png(logo, 32, path.join(web, 'favicon-32.png'));
|
|
await png(logo, 192, path.join(web, 'icon-192.png'));
|
|
await png(logo, 512, path.join(web, 'icon-512.png'));
|
|
await sharp(logo, { density: 400 }).resize(180, 180).flatten({ background: '#0e1120' }).png().toFile(path.join(web, 'apple-touch-icon.png'));
|
|
|
|
const densities = { mdpi: 1, hdpi: 1.5, xhdpi: 2, xxhdpi: 3, xxxhdpi: 4 };
|
|
for (const [d, f] of Object.entries(densities)) {
|
|
const dir = path.join(res, `mipmap-${d}`);
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
await png(logo, Math.round(48 * f), path.join(dir, 'ic_launcher.png'));
|
|
// adaptive foreground: 108dp canvas, artwork inside the 66dp-ish safe zone
|
|
const canvas = Math.round(108 * f);
|
|
const art = Math.round(canvas * 0.70);
|
|
const artBuf = await sharp(mark, { density: 400 }).resize(art, art).png().toBuffer();
|
|
await sharp({ create: { width: canvas, height: canvas, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } } })
|
|
.composite([{ input: artBuf, gravity: 'center' }]).png().toFile(path.join(dir, 'ic_launcher_foreground.png'));
|
|
}
|
|
fs.mkdirSync(path.join(res, 'drawable-nodpi'), { recursive: true });
|
|
await png(logo, 384, path.join(res, 'drawable-nodpi', 'logo.png'));
|
|
console.log('icons rendered');
|