MonEspacePro/docs/app-ios/store/render.js

24 lines
1.4 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. 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 });
await browser.close();
console.log(`${NAMES.length} captures dans ${out}`);
})();