feat(cli,producer): add gif output format with two-pass palette encode (#1333)

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
Matt Van Horn
2026-06-10 21:17:55 -04:00
committed by GitHub
co-authored by Matt Van Horn
parent e0ecd4d2d1
commit e6b8d66c2d
13 changed files with 385 additions and 29 deletions
+25
View File
@@ -219,3 +219,28 @@ export function resolveCompositionEntryArg(
}
return result.value;
}
export type GifLoopParseResult =
| { ok: true; value: number | undefined }
| { ok: false; message: string };
/**
* Parse and validate `--gif-loop <count>` (GIF Netscape loop count).
* Returns `{ ok: true, value: undefined }` when the flag is absent so the
* caller can apply the format-dependent default (0 = infinite for gif).
*/
export function parseGifLoopArg(raw: string | undefined): GifLoopParseResult {
if (raw === undefined) return { ok: true, value: undefined };
const trimmed = raw.trim();
if (trimmed.length === 0) {
return { ok: false, message: "GIF loop count must not be empty." };
}
const parsed = Number(trimmed);
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65_535) {
return {
ok: false,
message: `Got "${raw}". GIF loop count must be an integer between 0 and 65535.`,
};
}
return { ok: true, value: parsed };
}