feat(m4): cap map images at Full HD and shrink on import (#85)
The owner fixed the map cap at 1920 px on the long side and 1080 px on the short side (either orientation). fff-vtt import now shrinks a larger source with ImageMagick Lanczos before tiling (alpha kept, proportions preserved, no upscaling), prints `scaled WxH -> WxH`, and records the shrunk w/h; a source at or below the cap is untouched, so the pixel-identity tests still hold. A scene row already above the cap is not rewritten: the server logs `map_above_cap` at startup and serve prints the re-import advice. Docs: ADR-0023, DESIGN 3.3/5.3/8/11.1/13/14, TESTING 5.3/13, README, HANDOFF-M4, client README. The M4 phone gate and the fogbench measurement now use the Full HD maximum; the 16384 px / 262144-cell bench and test rows stay as labelled server stress references. import-scale now proves a 16384² input is shrunk to 1080x1080 (289 tiles at 64 px) quickly and bounded. Part of #63, #85. #77 is blocked by this issue.
This commit is contained in:
+28
-7
@@ -127,23 +127,32 @@ function importImage(opts, stateDir) {
|
||||
}
|
||||
}
|
||||
|
||||
/** The map a no-image start will serve, read from the state db without starting anything. */
|
||||
function describeScene(stateDir) {
|
||||
// The Full HD map cap (FIXED owner decision 2026-11-21, #85); the server warns in its own log,
|
||||
// this is the same warning on the console where the operator actually looks.
|
||||
const CAP_LONG = 1920
|
||||
const CAP_SHORT = 1080
|
||||
|
||||
function readSceneRow(stateDir) {
|
||||
const dbFile = path.join(stateDir, 'state.db')
|
||||
if (!fs.existsSync(dbFile)) return 'fresh state: default 4096x4096, tile 32, art v1'
|
||||
if (!fs.existsSync(dbFile)) return { text: 'fresh state: default 4096x4096, tile 32, art v1' }
|
||||
let db
|
||||
try {
|
||||
db = new DatabaseSync(dbFile, { readOnly: true })
|
||||
const row = db.prepare('SELECT w, h, tile_size, art_version FROM scene WHERE id = 1').get()
|
||||
if (!row) return `no scene row in ${dbFile}`
|
||||
return `${row.w}x${row.h}, tile ${row.tile_size}, art v${row.art_version}`
|
||||
if (!row) return { text: `no scene row in ${dbFile}` }
|
||||
return { row, text: `${row.w}x${row.h}, tile ${row.tile_size}, art v${row.art_version}` }
|
||||
} catch (e) {
|
||||
return `unreadable ${dbFile} (${e.message})`
|
||||
return { text: `unreadable ${dbFile} (${e.message})` }
|
||||
} finally {
|
||||
db?.close()
|
||||
}
|
||||
}
|
||||
|
||||
/** The map a no-image start will serve, read from the state db without starting anything. */
|
||||
function describeScene(stateDir) {
|
||||
return readSceneRow(stateDir).text
|
||||
}
|
||||
|
||||
/** `--dry-run`: prove the `--` arguments reached this script, then exit without side effects. */
|
||||
function printDryRun(opts, stateDir) {
|
||||
const lines = [
|
||||
@@ -157,7 +166,14 @@ function printDryRun(opts, stateDir) {
|
||||
` image: ${opts.image ? path.resolve(opts.image) : '<none, keeping current map>'}`,
|
||||
` tile-size: ${opts.tileSize ?? '<none>'}`,
|
||||
]
|
||||
if (!opts.image) lines.push(` current map: ${describeScene(stateDir)}`)
|
||||
if (!opts.image) {
|
||||
lines.push(` current map: ${describeScene(stateDir)}`)
|
||||
const { row } = readSceneRow(stateDir)
|
||||
if (row && (Math.max(row.w, row.h) > CAP_LONG || Math.min(row.w, row.h) > CAP_SHORT)) {
|
||||
lines.push(` WARNING: map is ${row.w}x${row.h}, above the Full HD cap ` +
|
||||
`(at most ${CAP_LONG} px long side, ${CAP_SHORT} px short side); re-import to shrink.`)
|
||||
}
|
||||
}
|
||||
process.stdout.write(lines.join('\n') + '\n')
|
||||
}
|
||||
|
||||
@@ -213,6 +229,11 @@ function printStartup(handle) {
|
||||
if (!fs.existsSync(distDir)) {
|
||||
lines.push(`WARNING: no client build at ${distDir}; "/" will 404 until it is built.`, '')
|
||||
}
|
||||
const { row } = readSceneRow(stateDir)
|
||||
if (row && (Math.max(row.w, row.h) > CAP_LONG || Math.min(row.w, row.h) > CAP_SHORT)) {
|
||||
lines.push(`WARNING: map is ${row.w}x${row.h}, above the Full HD cap ` +
|
||||
`(at most ${CAP_LONG} px long side, ${CAP_SHORT} px short side); re-import to shrink.`, '')
|
||||
}
|
||||
lines.push('The certificate only names this LAN address; if the laptop\'s address changes,',
|
||||
'`devbox run serve` regenerates it and prints these steps again.', '')
|
||||
process.stdout.write(lines.join('\n') + '\n')
|
||||
|
||||
Reference in New Issue
Block a user