存档点
This commit is contained in:
35
convert.js
Normal file
35
convert.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const sharp = require('sharp');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const icons = [
|
||||
{ svg: 'static/tab-home.svg', png: 'static/tab-home.png' },
|
||||
{ svg: 'static/tab-home-active.svg', png: 'static/tab-home-active.png' },
|
||||
{ svg: 'static/tab-game.svg', png: 'static/tab-game.png' },
|
||||
{ svg: 'static/tab-game-active.svg', png: 'static/tab-game-active.png' },
|
||||
{ svg: 'static/tab-mine.svg', png: 'static/tab-mine.png' },
|
||||
{ svg: 'static/tab-mine-active.svg', png: 'static/tab-mine-active.png' }
|
||||
];
|
||||
|
||||
async function convertSvgToPng() {
|
||||
console.log('开始转换SVG到PNG...');
|
||||
|
||||
for (const icon of icons) {
|
||||
try {
|
||||
const svgBuffer = fs.readFileSync(icon.svg);
|
||||
|
||||
await sharp(svgBuffer)
|
||||
.resize(81, 81)
|
||||
.png()
|
||||
.toFile(icon.png);
|
||||
|
||||
console.log(`✓ ${icon.svg} -> ${icon.png}`);
|
||||
} catch (error) {
|
||||
console.error(`✗ 转换失败: ${icon.svg}`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('转换完成!');
|
||||
}
|
||||
|
||||
convertSvgToPng().catch(console.error);
|
||||
Reference in New Issue
Block a user