-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-pwa-icons.js
More file actions
31 lines (25 loc) · 970 Bytes
/
generate-pwa-icons.js
File metadata and controls
31 lines (25 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Jimp } from 'jimp';
import path from 'path';
async function generatePWAIcons() {
try {
const sourceIcon = path.resolve('src-tauri/icons/icon.png');
const publicDir = path.resolve('src/public');
const image = await Jimp.read(sourceIcon);
console.log(`Source icon read: ${image.width}x${image.height}`);
const targets = [
{ name: 'pwa-192x192.png', size: 192 },
{ name: 'pwa-512x512.png', size: 512 },
{ name: 'apple-touch-icon.png', size: 180 }
];
for (const target of targets) {
const resized = image.clone().resize({ w: target.size, h: target.size });
const outputPath = path.join(publicDir, target.name);
await resized.write(outputPath);
console.log(`Generated: ${target.name} (${target.size}x${target.size})`);
}
console.log('PWA icons updated successfully.');
} catch (error) {
console.error('Error generating PWA icons:', error);
}
}
generatePWAIcons();