80 Zeilen
3.0 KiB
JavaScript
80 Zeilen
3.0 KiB
JavaScript
const sharp = require('sharp');
|
|
const fs = require('fs').promises;
|
|
const path = require('path');
|
|
|
|
// Icon-Größen für PWA
|
|
const sizes = [48, 72, 96, 128, 144, 152, 192, 384, 512];
|
|
|
|
async function generateIcons() {
|
|
const svgPath = path.join(__dirname, 'frontend/assets/icons/taskmate-logo.svg');
|
|
const outputDir = path.join(__dirname, 'frontend/assets/icons');
|
|
|
|
try {
|
|
// SVG einlesen
|
|
const svgBuffer = await fs.readFile(svgPath);
|
|
|
|
// Icons in verschiedenen Größen generieren
|
|
for (const size of sizes) {
|
|
const outputPath = path.join(outputDir, `icon-${size}x${size}.png`);
|
|
|
|
await sharp(svgBuffer)
|
|
.resize(size, size)
|
|
.png()
|
|
.toFile(outputPath);
|
|
|
|
console.log(`✓ Erstellt: icon-${size}x${size}.png`);
|
|
}
|
|
|
|
// Zusätzliche Icons für Shortcuts
|
|
// Add Task Icon
|
|
const addTaskSvg = `<svg width="96" height="96" viewBox="0 0 96 96" xmlns="http://www.w3.org/2000/svg">
|
|
<rect width="96" height="96" rx="16" fill="#0A1832"/>
|
|
<path d="M48 24v48M24 48h48" stroke="#00D4FF" stroke-width="6" stroke-linecap="round"/>
|
|
</svg>`;
|
|
|
|
await sharp(Buffer.from(addTaskSvg))
|
|
.png()
|
|
.toFile(path.join(outputDir, 'add-task-96x96.png'));
|
|
console.log('✓ Erstellt: add-task-96x96.png');
|
|
|
|
// Calendar Icon
|
|
const calendarSvg = `<svg width="96" height="96" viewBox="0 0 96 96" xmlns="http://www.w3.org/2000/svg">
|
|
<rect width="96" height="96" rx="16" fill="#0A1832"/>
|
|
<rect x="20" y="28" width="56" height="48" rx="4" stroke="#C8A851" stroke-width="4" fill="none"/>
|
|
<path d="M32 20v16M64 20v16M20 44h56" stroke="#C8A851" stroke-width="4" stroke-linecap="round"/>
|
|
</svg>`;
|
|
|
|
await sharp(Buffer.from(calendarSvg))
|
|
.png()
|
|
.toFile(path.join(outputDir, 'calendar-96x96.png'));
|
|
console.log('✓ Erstellt: calendar-96x96.png');
|
|
|
|
// Favicon erstellen (mehrere Größen in einer ICO-Datei)
|
|
await sharp(svgBuffer)
|
|
.resize(32, 32)
|
|
.png()
|
|
.toFile(path.join(outputDir, 'favicon-32x32.png'));
|
|
console.log('✓ Erstellt: favicon-32x32.png');
|
|
|
|
await sharp(svgBuffer)
|
|
.resize(16, 16)
|
|
.png()
|
|
.toFile(path.join(outputDir, 'favicon-16x16.png'));
|
|
console.log('✓ Erstellt: favicon-16x16.png');
|
|
|
|
// Apple Touch Icon
|
|
await sharp(svgBuffer)
|
|
.resize(180, 180)
|
|
.png()
|
|
.toFile(path.join(outputDir, 'apple-touch-icon.png'));
|
|
console.log('✓ Erstellt: apple-touch-icon.png');
|
|
|
|
console.log('\n✅ Alle Icons wurden erfolgreich generiert!');
|
|
|
|
} catch (error) {
|
|
console.error('Fehler beim Generieren der Icons:', error);
|
|
}
|
|
}
|
|
|
|
// Script ausführen
|
|
generateIcons(); |