MonEspacePro/docs/app-ios/store/render.js
2026-10-15 11:45:10 +02:00

39 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Rend panorama.html et le découpe en 5 captures App Store 1320 × 2868 (JPEG : aucune couche alpha, exigé par Apple),
// plus un aperçu du panorama complet, le format 6,3" et l'image d'en-tête. Usage : npm install && node render.js
const path = require('path');
const fs = require('fs');
const { chromium } = require('playwright-core');
const { pathToFileURL } = require('url');
const W = 1320, H = 2868, NAMES = ['01-accroche', '02-tampon', '03-recompenses', '04-statistiques', '05-campagnes'];
(async () => {
const out = path.join(__dirname, 'export');
fs.mkdirSync(out, { recursive: true });
const browser = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe', headless: true });
const page = await browser.newPage({ viewport: { width: W * NAMES.length, height: H }, deviceScaleFactor: 1 });
await page.goto(pathToFileURL(path.join(__dirname, 'panorama.html')).href);
await page.evaluate(() => document.fonts.ready);
await page.waitForLoadState('networkidle');
for (const [i, name] of NAMES.entries()) {
await page.screenshot({ path: path.join(out, `${name}.jpg`), type: 'jpeg', quality: 95, clip: { x: i * W, y: 0, width: W, height: H }, omitBackground: false });
}
await page.screenshot({ path: path.join(out, 'apercu-panorama.jpg'), type: 'jpeg', quality: 85 });
// Format 6,3" (1206 × 2622) : celui qu'App Store Connect demande pour « iPhone avec Dynamic Island ».
const small = await browser.newPage({ viewport: { width: 1206, height: 2622 }, deviceScaleFactor: 1 });
fs.mkdirSync(path.join(out, '6.3'), { recursive: true });
for (const name of NAMES) {
const src = 'data:image/jpeg;base64,' + fs.readFileSync(path.join(out, `${name}.jpg`)).toString('base64');
await small.setContent(`<body style="margin:0"><img src="${src}" style="display:block;width:1206px;height:2622px"></body>`);
await small.screenshot({ path: path.join(out, '6.3', `${name}.jpg`), type: 'jpeg', quality: 95 });
}
// Image d'en-tête de la page produit (3840 × 1646).
const header = await browser.newPage({ viewport: { width: 3840, height: 1646 }, deviceScaleFactor: 1 });
await header.goto(pathToFileURL(path.join(__dirname, 'entete.html')).href);
await header.evaluate(() => document.fonts.ready);
await header.waitForLoadState('networkidle');
await header.screenshot({ path: path.join(out, 'entete.jpg'), type: 'jpeg', quality: 95 });
await browser.close();
console.log(`${NAMES.length} captures dans ${out}`);
})();