SPB Git

Repository Public

make-brand-assets.mjs 6.6 KB 122 lines javascript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : agentilab-web8 * File             : scripts/make-brand-assets.mjs9 * Module           : Scripts10 * Repository       : https://git.spboucher.ai/agentilab-web11 * Project Website  : Not specified12 * Created          : 2026-12-0513 * Last Modified    : 2026-12-0514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : Proprietary34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// Génère les actifs de marque à partir des sources SVG éditables de44// public/images/brand/ : favicon (SVG, PNG 32, ICO), apple-touch-icon,45// symbole PNG 512 (JSON-LD) et visuel Open Graph 1200×630.46// Usage : node scripts/make-brand-assets.mjs47import { mkdir, writeFile } from 'node:fs/promises';48import path from 'node:path';49import { fileURLToPath } from 'node:url';50import sharp from 'sharp';5152const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');53const brandDir = path.join(root, 'public', 'images', 'brand');54await mkdir(brandDir, { recursive: true });5556const INK = '#090e19';57const PAPER = '#f7f9fc';58const BLUE = '#528cdb';59const SLATE = '#66758a';6061/** Tracés du symbole dans une boîte 32×32. */62const mark = (stroke, accent = BLUE) => `63  <path d="M6.5 26 16 5.5 25.5 26" fill="none" stroke="${stroke}" stroke-width="2.6" stroke-linejoin="round" stroke-linecap="round"/>64  <path d="M3.5 21.5C9 14.2 21 13.4 27.6 18.4" fill="none" stroke="${accent}" stroke-width="2.2" stroke-linecap="round"/>65  <circle cx="27.6" cy="18.4" r="2.6" fill="${accent}"/>`;6667const svg = (w, h, body, viewBox = `0 0 ${w} ${h}`) =>68  `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="${viewBox}">${body}</svg>\n`;69const FONT = `font-family="-apple-system, 'Helvetica Neue', 'Segoe UI', Arial, sans-serif"`;7071const files = {72  // Symbole seul73  'agentilab-symbol.svg': svg(32, 32, mark(INK)),74  'agentilab-symbol-mono-dark.svg': svg(32, 32, mark(INK, INK)),75  'agentilab-symbol-mono-light.svg': svg(32, 32, mark(PAPER, PAPER)),76  // Logo horizontal (le texte utilise une pile de polices système)77  'agentilab-logo.svg': svg(78    300, 48,79    `<g transform="translate(4 8)">${mark(INK)}</g><text x="48" y="33" ${FONT} font-size="25" font-weight="650" letter-spacing="-0.7" fill="${INK}">AgentiLab <tspan font-weight="400" fill="${SLATE}">Technologies</tspan></text>`,80  ),81  'agentilab-logo-light.svg': svg(82    300, 48,83    `<g transform="translate(4 8)">${mark(PAPER)}</g><text x="48" y="33" ${FONT} font-size="25" font-weight="650" letter-spacing="-0.7" fill="${PAPER}">AgentiLab <tspan font-weight="400" fill="#a6b1c2">Technologies</tspan></text>`,84  ),85};86for (const [name, content] of Object.entries(files)) await writeFile(path.join(brandDir, name), content);8788// Icône d’application : symbole clair sur carré d’encre.89const icon = (size, radius) =>90  svg(size, size, `<rect width="64" height="64" rx="${radius}" fill="${INK}"/><g transform="translate(10 9) scale(1.4)">${mark(PAPER)}</g>`, '0 0 64 64');91await writeFile(path.join(root, 'public', 'icon.svg'), icon(64, 14));92const png = (source, size) => sharp(Buffer.from(source), { density: 300 }).resize(size, size).png().toBuffer();93const png32 = await png(icon(64, 14), 32);94await writeFile(path.join(root, 'public', 'favicon-32.png'), png32);95await writeFile(path.join(root, 'public', 'apple-touch-icon.png'), await png(icon(64, 0), 180));96await writeFile(path.join(brandDir, 'agentilab-symbol-512.png'), await png(icon(64, 0), 512));9798// favicon.ico : conteneur ICO autour du PNG 32×32 (format admis par tous les navigateurs actuels).99const header = Buffer.alloc(22);100header.writeUInt16LE(0, 0); header.writeUInt16LE(1, 2); header.writeUInt16LE(1, 4);101header.writeUInt8(32, 6); header.writeUInt8(32, 7); header.writeUInt8(0, 8); header.writeUInt8(0, 9);102header.writeUInt16LE(1, 10); header.writeUInt16LE(32, 12);103header.writeUInt32LE(png32.length, 14); header.writeUInt32LE(22, 18);104await writeFile(path.join(root, 'public', 'favicon.ico'), Buffer.concat([header, png32]));105106// Visuel Open Graph 1200×630 (neutre : il sert aux deux langues).107const og = svg(108  1200, 630,109  `<rect width="1200" height="630" fill="${INK}"/>110   <g fill="none" stroke="#263044"><circle cx="940" cy="315" r="150"/><circle cx="940" cy="315" r="250" stroke-dasharray="3 9"/><circle cx="940" cy="315" r="350"/></g>111   <circle cx="940" cy="315" r="62" fill="${PAPER}"/>112   <g transform="translate(905 279) scale(2.2)">${mark(INK)}</g>113   <circle cx="1117" cy="138" r="13" fill="${BLUE}"/><circle cx="745" cy="471" r="9" fill="${PAPER}"/><circle cx="1203" cy="545" r="7" fill="${SLATE}"/>114   <g transform="translate(80 84) scale(1.6)">${mark(PAPER)}</g>115   <text x="146" y="123" ${FONT} font-size="34" font-weight="650" letter-spacing="-0.8" fill="${PAPER}">AgentiLab <tspan font-weight="400" fill="#a6b1c2">Technologies</tspan></text>116   <text ${FONT} font-size="68" font-weight="640" letter-spacing="-2.4" fill="${PAPER}"><tspan x="80" y="330">Société québécoise</tspan><tspan x="80" y="408">de développement</tspan><tspan x="80" y="486">de logiciels</tspan></text>117   <text x="80" y="556" font-family="Menlo, monospace" font-size="20" letter-spacing="2" fill="#a6b1c2">WWW.AGENTILAB.AI  ·  QUÉBEC, CANADA</text>`,118);119await writeFile(path.join(brandDir, 'og-source.svg'), og);120await sharp(Buffer.from(og), { density: 72 }).resize(1200, 630).png({ compressionLevel: 9, palette: true }).toFile(path.join(root, 'public', 'og.png'));121console.log('Actifs de marque générés dans public/ et public/images/brand/.');122
Files main
Menu

Theme