installer: shrink launcher profile icon to 64x64 data URL
256x256(~44KB base64) 아이콘은 일부 마인크래프트 런처에서 렌더링되지 않고 기본 아이콘(화로)으로 폴백한다. 프로필 아이콘은 작은 타일로 표시되므로 sharp 로 64x64(~8KB base64) 로 다운스케일해 안정적으로 표시되게 한다. exe 아이콘(build/icon.*)은 256x256 그대로 유지. v0.3.7. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minecraft-music-quiz-installer",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.7",
|
||||
"description": "마인크래프트 음악퀴즈 간편설치기 + 관리 사이트",
|
||||
"main": "dist/installer/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -8,26 +8,44 @@
|
||||
// build/ 폴더는 electron-builder 가 exe 아이콘으로만 쓰고 asar 에
|
||||
// 포함되지 않아서, 런타임에 그 파일을 읽을 수 없다. 대신 빌드(개발) 시점에
|
||||
// 이 스크립트를 돌려 PNG 를 소스 코드에 인라인한다.
|
||||
//
|
||||
// 프로필 아이콘은 작은 타일로 렌더링되므로 64x64 로 다운스케일해서 박는다.
|
||||
// 원본 256x256 (~44KB base64) 을 그대로 쓰면 data URL 이 지나치게 커져
|
||||
// 일부 런처에서 아이콘을 렌더링하지 못하고 기본 아이콘(화로)으로 폴백한다.
|
||||
// exe 아이콘(build/icon.ico, build/icon.png)은 256x256 그대로 둔다.
|
||||
|
||||
'use strict'
|
||||
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const sharp = require('sharp')
|
||||
|
||||
const repoRoot = path.resolve(__dirname, '..')
|
||||
const pngPath = path.join(repoRoot, 'build', 'icon.png')
|
||||
const tsPath = path.join(repoRoot, 'src', 'installer', 'launcherIcon.ts')
|
||||
|
||||
const buf = fs.readFileSync(pngPath)
|
||||
const ICON_SIZE = 64
|
||||
|
||||
async function main() {
|
||||
const buf = await sharp(pngPath)
|
||||
.resize(ICON_SIZE, ICON_SIZE, { fit: 'cover' })
|
||||
.png({ compressionLevel: 9 })
|
||||
.toBuffer()
|
||||
const b64 = buf.toString('base64')
|
||||
|
||||
const ts = `// AUTO-GENERATED by scripts/build-launcher-icon.cjs from build/icon.png.
|
||||
// 마인크래프트 런처의 "설치 설정" 화면에서 보이는 프로필 아이콘. exe 와 같은
|
||||
// 이미지를 쓰기 위해 빌드 시점에 PNG 를 data URL 로 인라인한다. 변경하려면
|
||||
// build/icon.png 교체 후 \`node scripts/build-launcher-icon.cjs\` 재실행.
|
||||
// 이미지를 ${ICON_SIZE}x${ICON_SIZE} 로 줄여 빌드 시점에 data URL 로 인라인한다.
|
||||
// 변경하려면 build/icon.png 교체 후 \`node scripts/build-launcher-icon.cjs\` 재실행.
|
||||
export const LAUNCHER_PROFILE_ICON =
|
||||
'data:image/png;base64,${b64}'
|
||||
`
|
||||
|
||||
fs.writeFileSync(tsPath, ts, 'utf8')
|
||||
console.log(`wrote ${tsPath} (${buf.length} bytes PNG → ${b64.length} chars base64)`)
|
||||
console.log(`wrote ${tsPath} (${ICON_SIZE}x${ICON_SIZE}, ${buf.length} bytes PNG → ${b64.length} chars base64)`)
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user