Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const USAGE = `Usage:
icon style <${Object.keys(STYLES).join('|')}|agentic|all> [DRAW OPTIONS]

DRAW OPTIONS: [--out DIR] [--only mail,鈥 [--no-draw] [--draw-only] [--force]
[--concurrency N] [--quality low|medium|high]
[--concurrency N] [--quality low|medium|high] [--model M]
[--style-dir DIR] [--dry-run]

A colour style draws every UI icon with an image model (needs OPENAI_API_KEY),
Expand Down Expand Up @@ -133,7 +133,7 @@ if (isMain(import.meta.url)) {
try {
const { flags, values, positional } = parseArgs(process.argv.slice(2), {
boolean: ['--json', '--help', '--no-draw', '--draw-only', '--force', '--dry-run'],
string: ['-o', '--out', '--sizes', '--color', '--only', '--category', '--mode', '--concurrency', '--quality', '--style-dir'],
string: ['-o', '--out', '--sizes', '--color', '--only', '--category', '--mode', '--concurrency', '--quality', '--style-dir', '--model'],
});
const [verb, ...rest] = positional;
if (flags.has('--help') || !verb) {
Expand Down Expand Up @@ -275,6 +275,7 @@ if (isMain(import.meta.url)) {
styleDir: values.get('--style-dir') ?? join(process.env['HOME'] ?? '', 'brand-assets', 'openemoji', 'master'),
concurrency: Number(values.get('--concurrency') ?? HQ_CONCURRENCY),
quality,
...(values.get('--model') ? { model: values.get('--model')! } : {}),
force: flags.has('--force'),
log: (line) => process.stderr.write(`${line}\n`),
render: (svg, size) => Buffer.from(new Resvg(svg, { fitTo: { mode: 'width', value: size } }).render().asPng()),
Expand Down
10 changes: 8 additions & 2 deletions src/icon-hq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ export interface HqDrawOptions {
styleDir: string;
concurrency: number;
quality: string;
/**
* The image model; HQ_MODEL when absent. gpt-image-2 now answers
* "Transparent background is not supported for this model", so a top-up
* drawing (a new icon after the set shipped) needs one that still does.
*/
model?: string;
force: boolean;
log: (line: string) => void;
render: (svg: string, size: number) => Promise<Buffer> | Buffer;
Expand Down Expand Up @@ -202,7 +208,7 @@ export async function drawHq(options: HqDrawOptions): Promise<HqDrawReport> {
try {
report.calls += 1;
const result = await options.caller({
model: HQ_MODEL,
model: options.model ?? HQ_MODEL,
// A brand takes no style reference: the mark is the only thing the
// model should be looking at, and an emoji master beside it is an
// invitation to redraw.
Expand All @@ -213,7 +219,7 @@ export async function drawHq(options: HqDrawOptions): Promise<HqDrawReport> {
await writeFile(join(master, `${key}.png`), result.png);
await writeFile(
join(options.out, style.dir, 'prompts.jsonl'),
`${JSON.stringify({ key, style: style.id, prompt, brand: Boolean(brand), references: brand ? ['mark'] : ['line', ...style.emojiRefs] })}\n`,
`${JSON.stringify({ key, style: style.id, model: options.model ?? HQ_MODEL, prompt, brand: Boolean(brand), references: brand ? ['mark'] : ['line', ...style.emojiRefs] })}\n`,
{ flag: 'a' },
);
report.drawn.push(key);
Expand Down
Loading