Validate story image PNG color modes

This commit is contained in:
2026-07-05 15:30:20 +09:00
parent 11d450fc04
commit 0493d40060

View File

@@ -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) {