mirror of
https://github.com/ElppaDev/snStatus.git
synced 2026-01-29 09:35:36 +00:00
최초 배포
This commit is contained in:
30
backend/data/convert_icons_exec.cjs
Normal file
30
backend/data/convert_icons_exec.cjs
Normal file
@@ -0,0 +1,30 @@
|
||||
const sharp = require('sharp');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// 이미 /app/data 내에서 실행되므로 현재 디렉토리가 data 폴더임
|
||||
const DATA_DIR = __dirname;
|
||||
const svgPath = path.join(DATA_DIR, 'icon.svg');
|
||||
|
||||
// icon.svg가 존재하는지 확인
|
||||
if (!fs.existsSync(svgPath)) {
|
||||
console.error(`File not found: ${svgPath}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const svgBuffer = fs.readFileSync(svgPath);
|
||||
|
||||
async function convert() {
|
||||
try {
|
||||
console.log('Converting icons from:', svgPath);
|
||||
await sharp(svgBuffer).resize(64, 64).png().toFile(path.join(DATA_DIR, 'favicon.png'));
|
||||
await sharp(svgBuffer).resize(192, 192).png().toFile(path.join(DATA_DIR, 'pwa-192x192.png'));
|
||||
await sharp(svgBuffer).resize(512, 512).png().toFile(path.join(DATA_DIR, 'pwa-512x512.png'));
|
||||
await sharp(svgBuffer).resize(180, 180).png().toFile(path.join(DATA_DIR, 'apple-touch-icon.png'));
|
||||
console.log('Conversion complete. Files saved to:', DATA_DIR);
|
||||
} catch (err) {
|
||||
console.error('Error converting icons:', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
convert();
|
||||
Reference in New Issue
Block a user