feat: genasset 离线素材管线(oMLX SVG 生成 + svg2png 打包 + 对比点评回填)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// 用法: node svg2png.mjs <srcDir> <outDir> [width]
|
||||
// 把 srcDir 下所有 .svg 转为 outDir 下同名 .png(默认 800 宽,2x 高清)
|
||||
import sharp from 'sharp'
|
||||
import { readdirSync, mkdirSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
const [srcDir, outDir, widthArg] = process.argv.slice(2)
|
||||
const width = Number(widthArg) || 800
|
||||
mkdirSync(outDir, { recursive: true })
|
||||
let n = 0
|
||||
for (const f of readdirSync(srcDir)) {
|
||||
if (!f.endsWith('.svg')) continue
|
||||
const out = join(outDir, f.replace(/\.svg$/, '.png'))
|
||||
await sharp(join(srcDir, f)).resize({ width }).png().toFile(out)
|
||||
n++
|
||||
console.log('png:', out)
|
||||
}
|
||||
console.log(`done: ${n} files`)
|
||||
Reference in New Issue
Block a user