From 0493d400602cc2eb04eec730f0e2cb23d27596d9 Mon Sep 17 00:00:00 2001 From: Wickedness Date: Sun, 5 Jul 2026 15:30:20 +0900 Subject: [PATCH] Validate story image PNG color modes --- scripts/verify-story-image-asset-data.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/verify-story-image-asset-data.mjs b/scripts/verify-story-image-asset-data.mjs index ab46e7a..1677842 100644 --- a/scripts/verify-story-image-asset-data.mjs +++ b/scripts/verify-story-image-asset-data.mjs @@ -9,6 +9,10 @@ const storyAssetsSourcePath = join('src', 'game', 'data', 'storyAssets.ts'); const expectedStorySize = { width: 1672, height: 941 }; const expectedPortraitSize = { width: 1254, height: 1254 }; +const allowedPngColorTypes = new Map([ + [2, 'RGB'], + [6, 'RGBA'] +]); const server = await createServer({ logLevel: 'error', @@ -138,11 +142,17 @@ function validatePngFile(errors, path, expectedSize, label) { const width = bytes.readUInt32BE(16); const height = bytes.readUInt32BE(20); + const bitDepth = bytes[24]; + const colorType = bytes[25]; if (width !== expectedSize.width || height !== expectedSize.height) { errors.push( `${path}: ${label} should be ${expectedSize.width}x${expectedSize.height}, got ${width}x${height}` ); } + if (bitDepth !== 8 || !allowedPngColorTypes.has(colorType)) { + const colorMode = allowedPngColorTypes.get(colorType) ?? `color type ${colorType}`; + errors.push(`${path}: ${label} should be 8-bit RGB/RGBA PNG, got ${bitDepth}-bit ${colorMode}`); + } } function validateRuntimeUrl(errors, key, url, path) {