egaki 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +167 -0
- package/dist/cli/clone-generate.d.ts +1 -0
- package/dist/cli/clone-generate.d.ts.map +1 -1
- package/dist/cli/clone-generate.js +1 -1
- package/dist/cli/generate.d.ts +3 -1
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +12 -5
- package/dist/cli/model-catalog.d.ts.map +1 -1
- package/dist/cli/model-catalog.js +37 -0
- package/dist/cli/upscale-generate.d.ts +97 -0
- package/dist/cli/upscale-generate.d.ts.map +1 -0
- package/dist/cli/upscale-generate.js +300 -0
- package/dist/cli/upscale-generate.test.d.ts +2 -0
- package/dist/cli/upscale-generate.test.d.ts.map +1 -0
- package/dist/cli/upscale-generate.test.js +92 -0
- package/dist/cli/voice-change-generate.d.ts +39 -0
- package/dist/cli/voice-change-generate.d.ts.map +1 -0
- package/dist/cli/voice-change-generate.js +123 -0
- package/dist/vite/angled-screen-shader.d.ts +4 -39
- package/dist/vite/angled-screen-shader.d.ts.map +1 -1
- package/dist/vite/angled-screen-shader.js +36 -440
- package/dist/vite/angled-screen.d.ts.map +1 -1
- package/dist/vite/angled-screen.js +9 -7
- package/dist/vite/shader-renderer.d.ts +0 -4
- package/dist/vite/shader-renderer.d.ts.map +1 -1
- package/dist/vite/shader-renderer.js +2 -66
- package/package.json +10 -5
- package/src/cli/cli.ts +227 -0
- package/src/cli/clone-generate.ts +1 -1
- package/src/cli/generate.ts +18 -6
- package/src/cli/model-catalog.ts +39 -0
- package/src/cli/upscale-generate.test.ts +96 -0
- package/src/cli/upscale-generate.ts +395 -0
- package/src/cli/voice-change-generate.ts +187 -0
- package/src/vite/angled-screen-shader.tsx +45 -498
- package/src/vite/angled-screen.tsx +9 -7
- package/src/vite/shader-renderer.tsx +7 -78
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "egaki",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI image, video, and speech generation CLI with MDX-to-video framework",
|
|
6
6
|
"main": "./dist/cli/main.js",
|
|
@@ -48,7 +48,9 @@
|
|
|
48
48
|
"default": "./src/vite/*.tsx"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
"bin":
|
|
51
|
+
"bin": {
|
|
52
|
+
"egaki": "dist/cli/main.js"
|
|
53
|
+
},
|
|
52
54
|
"repository": {
|
|
53
55
|
"type": "git",
|
|
54
56
|
"url": "https://github.com/remorses/egaki.git",
|
|
@@ -87,6 +89,8 @@
|
|
|
87
89
|
"@ai-sdk/replicate": "2.0.20",
|
|
88
90
|
"@ai-sdk/xai": "^3.0.139",
|
|
89
91
|
"@clack/prompts": "^1.0.1",
|
|
92
|
+
"@egaki/angled-screen": "^0.1.0",
|
|
93
|
+
"@egaki/midjourney": "^0.1.0",
|
|
90
94
|
"@fal-ai/client": "^1.10.1",
|
|
91
95
|
"@remotion/media": "4.0.494",
|
|
92
96
|
"@remotion/player": "4.0.494",
|
|
@@ -102,10 +106,11 @@
|
|
|
102
106
|
"mediabunny": "^1.50.8",
|
|
103
107
|
"moveable": "^0.53.0",
|
|
104
108
|
"picocolors": "^1.1.1",
|
|
105
|
-
"react": "19.
|
|
106
|
-
"react-dom": "19.
|
|
109
|
+
"react": "19.3.1",
|
|
110
|
+
"react-dom": "19.3.1",
|
|
107
111
|
"remotion": "4.0.494",
|
|
108
112
|
"safe-mdx": "^1.12.0",
|
|
113
|
+
"sharp": "^0.35.5",
|
|
109
114
|
"shiki": "^4.2.0",
|
|
110
115
|
"spiceflow": "1.26.0-rsc.7",
|
|
111
116
|
"string-dedent": "^3.0.2",
|
|
@@ -113,7 +118,7 @@
|
|
|
113
118
|
"tweakpane": "^4.0.5",
|
|
114
119
|
"vite": "^8.0.10",
|
|
115
120
|
"yaml": "^2.9.0",
|
|
116
|
-
"zod": "^4.
|
|
121
|
+
"zod": "^4.6.7",
|
|
117
122
|
"zustand": "^5.0.14"
|
|
118
123
|
},
|
|
119
124
|
"peerDependencies": {
|
package/src/cli/cli.ts
CHANGED
|
@@ -92,12 +92,21 @@ import {
|
|
|
92
92
|
cloneVoiceUncached as cloneVoice,
|
|
93
93
|
type CloneProvider,
|
|
94
94
|
} from './clone-generate.js'
|
|
95
|
+
import {
|
|
96
|
+
changeVoiceUncached as changeVoice,
|
|
97
|
+
VOICE_CHANGE_PROVIDER_IDS,
|
|
98
|
+
} from './voice-change-generate.js'
|
|
95
99
|
import {
|
|
96
100
|
detectBpm,
|
|
97
101
|
} from './bpm-detect.js'
|
|
98
102
|
import {
|
|
99
103
|
detectLoudness,
|
|
100
104
|
} from './loudness-detect.js'
|
|
105
|
+
import {
|
|
106
|
+
upscaleImageUncached as upscaleImage,
|
|
107
|
+
DEFAULT_UPSCALE_MODEL,
|
|
108
|
+
UPSCALE_MODELS,
|
|
109
|
+
} from './upscale-generate.js'
|
|
101
110
|
|
|
102
111
|
const cli = goke('egaki')
|
|
103
112
|
|
|
@@ -564,6 +573,94 @@ cli
|
|
|
564
573
|
}
|
|
565
574
|
})
|
|
566
575
|
|
|
576
|
+
// ─── upscale command ─────────────────────────────────────────────────────────
|
|
577
|
+
|
|
578
|
+
cli
|
|
579
|
+
.command(
|
|
580
|
+
'upscale <image>',
|
|
581
|
+
dedent`
|
|
582
|
+
Upscale an image: same image, more pixels and finer detail.
|
|
583
|
+
|
|
584
|
+
GPT Image models (default ${DEFAULT_UPSCALE_MODEL}) re-render the input
|
|
585
|
+
at a larger custom size with a strict "keep everything identical" prompt,
|
|
586
|
+
then match its colors to the input. Default size is the largest for the
|
|
587
|
+
aspect ratio: up to 3840px per edge and 8.3 MP. With OPENAI_API_KEY this
|
|
588
|
+
is one call. ChatGPT login returns only about 1.6 MP per call, so the
|
|
589
|
+
image is split into overlapping tiles (up to 16 calls) that are blended.
|
|
590
|
+
|
|
591
|
+
Midjourney (midjourney, midjourney-creative) upscales 2x through your
|
|
592
|
+
logged-in midjourney.com tab in Chrome via the Playwriter extension.
|
|
593
|
+
The input is cover-fit to Midjourney's frame for its aspect ratio, which
|
|
594
|
+
can crop a few pixels from one side.
|
|
595
|
+
|
|
596
|
+
Generative upscalers can change small details. Compare with the original.
|
|
597
|
+
`,
|
|
598
|
+
)
|
|
599
|
+
.option(
|
|
600
|
+
'-m, --model [model]',
|
|
601
|
+
z
|
|
602
|
+
.string()
|
|
603
|
+
.default(DEFAULT_UPSCALE_MODEL)
|
|
604
|
+
.describe(`Upscale model: ${UPSCALE_MODELS.join(', ')}`),
|
|
605
|
+
)
|
|
606
|
+
.option(
|
|
607
|
+
'-o, --output [path]',
|
|
608
|
+
z.string().describe('Output file path. Default: <input>-upscaled.<ext> next to the input'),
|
|
609
|
+
)
|
|
610
|
+
.option(
|
|
611
|
+
'--scale [factor]',
|
|
612
|
+
z.number().describe('Scale factor, e.g. 2. GPT Image default: the largest size the model allows. Midjourney: always 2'),
|
|
613
|
+
)
|
|
614
|
+
.option(
|
|
615
|
+
'--prompt [text]',
|
|
616
|
+
z.string().describe('Extra instructions for GPT Image, or the job prompt for Midjourney (describe the image for midjourney-creative)'),
|
|
617
|
+
)
|
|
618
|
+
.option('--json', 'Output result metadata as JSON to stdout')
|
|
619
|
+
.example('# Upscale with GPT Image to the largest supported size')
|
|
620
|
+
.example('egaki upscale photo.jpg')
|
|
621
|
+
.example('# 2x with GPT Image')
|
|
622
|
+
.example('egaki upscale photo.jpg --scale 2 -o photo-2x.png')
|
|
623
|
+
.example('# Midjourney subtle 2x upscale (needs Chrome + Playwriter, logged into midjourney.com)')
|
|
624
|
+
.example('egaki upscale painting.jpg -m midjourney')
|
|
625
|
+
.example('# Midjourney creative upscale guided by a prompt')
|
|
626
|
+
.example('egaki upscale painting.jpg -m midjourney-creative --prompt "oil painting of cliffs in snow"')
|
|
627
|
+
.action(async (imagePath, options) => {
|
|
628
|
+
const model = options.model ?? DEFAULT_UPSCALE_MODEL
|
|
629
|
+
const image = await readInputSource(imagePath)
|
|
630
|
+
|
|
631
|
+
console.error(pc.dim(`Model: ${model}`))
|
|
632
|
+
console.error(pc.cyan('Upscaling...'))
|
|
633
|
+
|
|
634
|
+
const result = await runProviderCall('Upscale', () => upscaleImage({
|
|
635
|
+
image,
|
|
636
|
+
model,
|
|
637
|
+
scale: options.scale,
|
|
638
|
+
prompt: options.prompt,
|
|
639
|
+
}))
|
|
640
|
+
|
|
641
|
+
const ext = extensionFromMediaType(result.image.mediaType)
|
|
642
|
+
const defaultOutput = isUrl(imagePath)
|
|
643
|
+
? `egaki-upscaled${ext}`
|
|
644
|
+
: path.join(path.dirname(imagePath), `${path.parse(imagePath).name}-upscaled${ext}`)
|
|
645
|
+
const [savedFile] = saveGeneratedFiles([result.image], options.output ?? defaultOutput)
|
|
646
|
+
console.error(pc.dim(`Size: ${result.input.width}x${result.input.height} -> ${result.output.width}x${result.output.height}${result.tiles && result.tiles > 1 ? ` (${result.tiles} tiles)` : ''}`))
|
|
647
|
+
if (result.warning) console.error(pc.yellow(result.warning))
|
|
648
|
+
printCost(result.cost)
|
|
649
|
+
|
|
650
|
+
if (options.json) {
|
|
651
|
+
console.log(JSON.stringify({
|
|
652
|
+
model: result.model,
|
|
653
|
+
file: savedFile,
|
|
654
|
+
input: result.input,
|
|
655
|
+
output: result.output,
|
|
656
|
+
cost: result.cost,
|
|
657
|
+
...(result.tiles ? { tiles: result.tiles } : {}),
|
|
658
|
+
...(result.jobId ? { jobId: result.jobId } : {}),
|
|
659
|
+
...(result.warning ? { warning: result.warning } : {}),
|
|
660
|
+
}, null, 2))
|
|
661
|
+
}
|
|
662
|
+
})
|
|
663
|
+
|
|
567
664
|
// ─── video command ───────────────────────────────────────────────────────────
|
|
568
665
|
|
|
569
666
|
cli
|
|
@@ -1435,6 +1532,134 @@ cli
|
|
|
1435
1532
|
}
|
|
1436
1533
|
})
|
|
1437
1534
|
|
|
1535
|
+
// ─── voice change command ────────────────────────────────────────────────────
|
|
1536
|
+
|
|
1537
|
+
cli
|
|
1538
|
+
.command(
|
|
1539
|
+
'voice change [audio]',
|
|
1540
|
+
dedent`
|
|
1541
|
+
Re-speak an existing recording with another voice (speech-to-speech).
|
|
1542
|
+
Keeps the timing, emotion and delivery of the input; only the voice
|
|
1543
|
+
changes. Supports ElevenLabs (default) and Cartesia.
|
|
1544
|
+
|
|
1545
|
+
The target voice can be any voice ID from the provider's library or a
|
|
1546
|
+
voice made with 'egaki voice clone'. Output is MP3.
|
|
1547
|
+
|
|
1548
|
+
ElevenLabs models: eleven_multilingual_sts_v2 (default),
|
|
1549
|
+
eleven_english_sts_v2. Cartesia has no model option.
|
|
1550
|
+
`,
|
|
1551
|
+
)
|
|
1552
|
+
.option(
|
|
1553
|
+
'--voice [voice]',
|
|
1554
|
+
z
|
|
1555
|
+
.string()
|
|
1556
|
+
.describe('Target voice ID (required). From the provider voice library or egaki voice clone'),
|
|
1557
|
+
)
|
|
1558
|
+
.option(
|
|
1559
|
+
'-p, --provider [provider]',
|
|
1560
|
+
z
|
|
1561
|
+
.enum(VOICE_CHANGE_PROVIDER_IDS)
|
|
1562
|
+
.default('elevenlabs')
|
|
1563
|
+
.describe(`Voice change provider: ${VOICE_CHANGE_PROVIDER_IDS.join(', ')}`),
|
|
1564
|
+
)
|
|
1565
|
+
.option(
|
|
1566
|
+
'-m, --model [model]',
|
|
1567
|
+
z
|
|
1568
|
+
.string()
|
|
1569
|
+
.describe('Provider model ID. ElevenLabs: eleven_multilingual_sts_v2 (default), eleven_english_sts_v2'),
|
|
1570
|
+
)
|
|
1571
|
+
.option(
|
|
1572
|
+
'-o, --output [path]',
|
|
1573
|
+
z
|
|
1574
|
+
.string()
|
|
1575
|
+
.describe('Output file path. Default: <input>-<provider>.mp3 (or egaki-output.mp3 with --stdin)'),
|
|
1576
|
+
)
|
|
1577
|
+
.option(
|
|
1578
|
+
'--remove-background-noise',
|
|
1579
|
+
'ElevenLabs: remove background noise from the input before conversion',
|
|
1580
|
+
)
|
|
1581
|
+
.option(
|
|
1582
|
+
'--stdin',
|
|
1583
|
+
'Read audio from stdin instead of a file path',
|
|
1584
|
+
)
|
|
1585
|
+
.option(
|
|
1586
|
+
'--json',
|
|
1587
|
+
'Output result metadata as JSON to stdout',
|
|
1588
|
+
)
|
|
1589
|
+
.example('# Re-speak a voiceover with an ElevenLabs voice')
|
|
1590
|
+
.example('egaki voice change narration.wav --voice JBFqnCBsd6RMkjVDRZzb -o narration-george.mp3')
|
|
1591
|
+
.example('# Clean a noisy recording while changing the voice')
|
|
1592
|
+
.example('egaki voice change take.m4a --voice <voice-id> --remove-background-noise')
|
|
1593
|
+
.example('# Use Cartesia')
|
|
1594
|
+
.example('egaki voice change take.wav --voice f786b574-daa5-4673-aa0c-cbe3e8534c02 -p cartesia')
|
|
1595
|
+
.example('# Speak your own recording with a cloned voice')
|
|
1596
|
+
.example('egaki voice clone speaker.mp3 --name "Speaker" --provider elevenlabs')
|
|
1597
|
+
.example('egaki voice change my-take.wav --voice <voice-id>')
|
|
1598
|
+
.action(async (audioPath = '', options) => {
|
|
1599
|
+
if (!options.stdin && !audioPath) {
|
|
1600
|
+
console.error(pc.red('No audio provided. Pass an audio file path or use --stdin.'))
|
|
1601
|
+
process.exit(1)
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
const voice = options.voice
|
|
1605
|
+
if (!voice) {
|
|
1606
|
+
console.error(pc.red('Target voice is required. Use --voice <voice-id>.'))
|
|
1607
|
+
process.exit(1)
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
let audioData: Uint8Array
|
|
1611
|
+
let filename: string | undefined
|
|
1612
|
+
|
|
1613
|
+
if (options.stdin) {
|
|
1614
|
+
const chunks: Buffer[] = []
|
|
1615
|
+
for await (const chunk of process.stdin) {
|
|
1616
|
+
chunks.push(chunk)
|
|
1617
|
+
}
|
|
1618
|
+
audioData = new Uint8Array(Buffer.concat(chunks))
|
|
1619
|
+
} else {
|
|
1620
|
+
const resolved = path.resolve(audioPath)
|
|
1621
|
+
if (!fs.existsSync(resolved)) {
|
|
1622
|
+
console.error(pc.red(`File not found: ${resolved}`))
|
|
1623
|
+
process.exit(1)
|
|
1624
|
+
}
|
|
1625
|
+
audioData = new Uint8Array(fs.readFileSync(resolved))
|
|
1626
|
+
filename = path.basename(resolved)
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
const provider = options.provider ?? 'elevenlabs'
|
|
1630
|
+
|
|
1631
|
+
console.error(pc.dim(`Provider: ${provider}`))
|
|
1632
|
+
console.error(pc.dim(`Voice: ${voice}`))
|
|
1633
|
+
console.error(pc.dim(`Audio: ${options.stdin ? 'stdin' : audioPath} (${(audioData.length / 1024).toFixed(1)} KB)`))
|
|
1634
|
+
console.error(pc.cyan('Changing voice...'))
|
|
1635
|
+
|
|
1636
|
+
const result = await runProviderCall('Voice change', () => changeVoice({
|
|
1637
|
+
audio: audioData,
|
|
1638
|
+
voice,
|
|
1639
|
+
provider,
|
|
1640
|
+
model: options.model,
|
|
1641
|
+
filename,
|
|
1642
|
+
removeBackgroundNoise: options.removeBackgroundNoise || false,
|
|
1643
|
+
}))
|
|
1644
|
+
|
|
1645
|
+
const defaultOutput = options.stdin
|
|
1646
|
+
? 'egaki-output'
|
|
1647
|
+
: path.join(path.dirname(audioPath), `${path.parse(audioPath).name}-${provider}`)
|
|
1648
|
+
const finalPath = ensureExtension(options.output ?? defaultOutput, extensionFromMediaType(result.mediaType))
|
|
1649
|
+
fs.writeFileSync(finalPath, result.audio)
|
|
1650
|
+
console.error(pc.green(`Saved: ${finalPath}`))
|
|
1651
|
+
|
|
1652
|
+
if (options.json) {
|
|
1653
|
+
console.log(JSON.stringify({
|
|
1654
|
+
file: finalPath,
|
|
1655
|
+
provider: result.provider,
|
|
1656
|
+
model: result.model,
|
|
1657
|
+
voice,
|
|
1658
|
+
bytes: result.audio.length,
|
|
1659
|
+
}, null, 2))
|
|
1660
|
+
}
|
|
1661
|
+
})
|
|
1662
|
+
|
|
1438
1663
|
// ─── models command ──────────────────────────────────────────────────────────
|
|
1439
1664
|
|
|
1440
1665
|
cli
|
|
@@ -1714,6 +1939,8 @@ const FEATURED_IMAGE_MODELS = [
|
|
|
1714
1939
|
'gemini-2.5-flash-image',
|
|
1715
1940
|
'gemini-3.1-flash-image-preview',
|
|
1716
1941
|
'nano-banana-pro-preview',
|
|
1942
|
+
'gpt-image-2.6-sunburst',
|
|
1943
|
+
'gpt-image-2.6-flare',
|
|
1717
1944
|
'gpt-image-2.5-sunburst',
|
|
1718
1945
|
'gpt-image-2.5-flare',
|
|
1719
1946
|
'gpt-image-2',
|
|
@@ -67,7 +67,7 @@ function validateOptions(opts: CloneVoiceOptions): Error | void {
|
|
|
67
67
|
|
|
68
68
|
// ─── MIME type helper ───────────────────────────────────────────────────────
|
|
69
69
|
|
|
70
|
-
function mimeTypeFromFilename(filename?: string): string {
|
|
70
|
+
export function mimeTypeFromFilename(filename?: string): string {
|
|
71
71
|
if (!filename) return 'audio/mpeg'
|
|
72
72
|
const ext = filename.split('.').pop()?.toLowerCase()
|
|
73
73
|
const map: Record<string, string> = {
|
package/src/cli/generate.ts
CHANGED
|
@@ -65,7 +65,7 @@ export type ImageModelId =
|
|
|
65
65
|
| 'recraft-v2' | 'recraft-v3' | 'recraft-v4' | 'recraft-v4-pro' | 'recraft-v4.1' | 'recraft-v4.1-pro' | 'recraft-v4.1-utility' | 'recraft-v4.1-utility-pro'
|
|
66
66
|
| 'seedream-5.0-lite' | 'seedream-4.5' | 'seedream-4.0'
|
|
67
67
|
| 'grok-imagine-image' | 'grok-imagine-image-2.0' | 'grok-imagine-image-quality'
|
|
68
|
-
| 'dall-e-2' | 'dall-e-3' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-sunburst' | 'chatgpt-image-latest'
|
|
68
|
+
| 'dall-e-2' | 'dall-e-3' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.6-flare' | 'gpt-image-2.6-sunburst' | 'chatgpt-image-latest'
|
|
69
69
|
| (string & {})
|
|
70
70
|
|
|
71
71
|
/** Video model IDs from the catalog. Accepts arbitrary strings too. */
|
|
@@ -114,6 +114,8 @@ export interface GenerateImageOptions {
|
|
|
114
114
|
negativePrompt?: string
|
|
115
115
|
/** Only for text-model image generation (Gemini). */
|
|
116
116
|
imageSize?: '1K' | '2K' | '4K'
|
|
117
|
+
/** Exact output size for models with a `size` parameter (OpenAI). Overrides the aspect ratio fallback. */
|
|
118
|
+
size?: `${number}x${number}`
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
export interface GenerateImageResult {
|
|
@@ -496,6 +498,8 @@ export async function generateImageUncached(opts: GenerateImageOptions): Promise
|
|
|
496
498
|
seed: opts.seed,
|
|
497
499
|
maskImage: opts.maskImage,
|
|
498
500
|
inputImages,
|
|
501
|
+
quality: opts.quality,
|
|
502
|
+
size: opts.size,
|
|
499
503
|
})
|
|
500
504
|
}
|
|
501
505
|
|
|
@@ -513,6 +517,7 @@ export async function generateImageUncached(opts: GenerateImageOptions): Promise
|
|
|
513
517
|
resolution: opts.resolution,
|
|
514
518
|
outputFormat: opts.outputFormat,
|
|
515
519
|
negativePrompt: opts.negativePrompt,
|
|
520
|
+
size: opts.size,
|
|
516
521
|
})
|
|
517
522
|
}
|
|
518
523
|
|
|
@@ -627,6 +632,7 @@ async function generateWithImageModel(opts: {
|
|
|
627
632
|
resolution?: string
|
|
628
633
|
outputFormat?: string
|
|
629
634
|
negativePrompt?: string
|
|
635
|
+
size?: `${number}x${number}`
|
|
630
636
|
}): Promise<Error | GenerateImageResult> {
|
|
631
637
|
const config = getModelConfig(opts.model)
|
|
632
638
|
if (config instanceof Error) return config
|
|
@@ -635,9 +641,11 @@ async function generateWithImageModel(opts: {
|
|
|
635
641
|
// parameter, so the request is expressed through `size` + the prompt text.
|
|
636
642
|
const features = config.strategy === 'video' ? undefined : config.features
|
|
637
643
|
const supportsNativeAspectRatio = (features?.aspectRatios?.length ?? 0) > 0
|
|
638
|
-
const fallback =
|
|
639
|
-
? { prompt: opts.prompt, size:
|
|
640
|
-
:
|
|
644
|
+
const fallback = opts.size
|
|
645
|
+
? { prompt: opts.prompt, size: opts.size }
|
|
646
|
+
: supportsNativeAspectRatio
|
|
647
|
+
? { prompt: opts.prompt, size: undefined }
|
|
648
|
+
: aspectRatioFallback(opts.prompt, opts.aspectRatio, features?.sizes ?? [])
|
|
641
649
|
|
|
642
650
|
const imagePrompt = opts.inputImages.length > 0
|
|
643
651
|
? { text: fallback.prompt, images: opts.inputImages, ...(opts.maskImage ? { mask: opts.maskImage } : {}) }
|
|
@@ -771,6 +779,8 @@ async function generateWithResponsesApi(opts: {
|
|
|
771
779
|
seed?: number
|
|
772
780
|
maskImage?: Uint8Array
|
|
773
781
|
inputImages: Uint8Array[]
|
|
782
|
+
quality?: string
|
|
783
|
+
size?: `${number}x${number}`
|
|
774
784
|
}): Promise<Error | GenerateImageResult> {
|
|
775
785
|
if (opts.count !== 1) {
|
|
776
786
|
return new ValidationError('ChatGPT image generation currently supports exactly one output image.')
|
|
@@ -784,7 +794,9 @@ async function generateWithResponsesApi(opts: {
|
|
|
784
794
|
return new ValidationError('ChatGPT image generation does not support mask yet.')
|
|
785
795
|
}
|
|
786
796
|
|
|
787
|
-
const { prompt, size } =
|
|
797
|
+
const { prompt, size } = opts.size
|
|
798
|
+
? { prompt: opts.prompt, size: opts.size }
|
|
799
|
+
: aspectRatioFallback(opts.prompt, opts.aspectRatio, OPENAI_SIZES)
|
|
788
800
|
|
|
789
801
|
const storedAuth = getChatGptAuth()
|
|
790
802
|
if (!storedAuth?.accountId) {
|
|
@@ -819,7 +831,7 @@ async function generateWithResponsesApi(opts: {
|
|
|
819
831
|
{
|
|
820
832
|
type: 'image_generation',
|
|
821
833
|
model: opts.model,
|
|
822
|
-
quality: 'auto',
|
|
834
|
+
quality: opts.quality ?? 'auto',
|
|
823
835
|
output_format: 'png',
|
|
824
836
|
output_compression: 100,
|
|
825
837
|
moderation: 'auto',
|
package/src/cli/model-catalog.ts
CHANGED
|
@@ -950,6 +950,45 @@ export const CATALOG: ModelEntry[] = [
|
|
|
950
950
|
multipleImages: true,
|
|
951
951
|
},
|
|
952
952
|
},
|
|
953
|
+
// GPT Image 2.6 (changelog: https://developers.openai.com/api/docs/changelog, 2026-11-04).
|
|
954
|
+
// Quality levels and pricing are assumed equal to 2.5 until OpenAI's model pages confirm them.
|
|
955
|
+
{
|
|
956
|
+
id: 'gpt-image-2.6-flare',
|
|
957
|
+
name: 'GPT Image 2.6 Flare',
|
|
958
|
+
description:
|
|
959
|
+
'Fastest GPT Image 2.6 model for image generation and editing, with adjustable complexity. ' +
|
|
960
|
+
'Pricing assumed equal to gpt-image-2.5-flare.',
|
|
961
|
+
released: '2026-11-04',
|
|
962
|
+
...openaiImage25,
|
|
963
|
+
cost: { type: 'per-image', perImage: 0.053 },
|
|
964
|
+
features: {
|
|
965
|
+
editing: true,
|
|
966
|
+
inpainting: true,
|
|
967
|
+
aspectRatios: [],
|
|
968
|
+
sizes: ['1024x1024', '1536x1024', '1024x1536'],
|
|
969
|
+
seed: false,
|
|
970
|
+
multipleImages: true,
|
|
971
|
+
},
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
id: 'gpt-image-2.6-sunburst',
|
|
975
|
+
name: 'GPT Image 2.6 Sunburst',
|
|
976
|
+
description:
|
|
977
|
+
'Most capable GPT Image 2.6 model, for work where editing precision and reference ' +
|
|
978
|
+
'fidelity matter most. Slower than Flare. Pricing assumed equal to gpt-image-2.5-sunburst; ' +
|
|
979
|
+
'actual cost is usually higher because it spends more tokens per image.',
|
|
980
|
+
released: '2026-11-04',
|
|
981
|
+
...openaiImage25,
|
|
982
|
+
cost: { type: 'per-image', perImage: 0.053 },
|
|
983
|
+
features: {
|
|
984
|
+
editing: true,
|
|
985
|
+
inpainting: true,
|
|
986
|
+
aspectRatios: [],
|
|
987
|
+
sizes: ['1024x1024', '1536x1024', '1024x1536'],
|
|
988
|
+
seed: false,
|
|
989
|
+
multipleImages: true,
|
|
990
|
+
},
|
|
991
|
+
},
|
|
953
992
|
{
|
|
954
993
|
id: 'chatgpt-image-latest',
|
|
955
994
|
name: 'ChatGPT Image',
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
import { blendTiles, chooseGrid, gptUpscaleSize, planTiles } from './upscale-generate.js'
|
|
3
|
+
|
|
4
|
+
describe('gptUpscaleSize', () => {
|
|
5
|
+
test('picks a size inside every GPT Image limit, close to the requested scale', () => {
|
|
6
|
+
const cases = [
|
|
7
|
+
{ width: 992, height: 570 },
|
|
8
|
+
{ width: 992, height: 570, scale: 2 },
|
|
9
|
+
{ width: 1024, height: 1024 },
|
|
10
|
+
{ width: 1080, height: 1920 },
|
|
11
|
+
{ width: 3000, height: 1000 },
|
|
12
|
+
{ width: 400, height: 300, scale: 1.5 },
|
|
13
|
+
{ width: 600, height: 200, scale: 2 },
|
|
14
|
+
{ width: 4000, height: 3000, scale: 2 },
|
|
15
|
+
{ width: 3100, height: 1000 },
|
|
16
|
+
{ width: 800, height: 600, scale: 0.5 },
|
|
17
|
+
]
|
|
18
|
+
const results = cases.map((input) => {
|
|
19
|
+
const label = `${input.width}x${input.height} x${input.scale ?? 'max'}`
|
|
20
|
+
const size = gptUpscaleSize(input)
|
|
21
|
+
if (size instanceof Error) return `${label}: ${size.message}`
|
|
22
|
+
const pixels = size.width * size.height
|
|
23
|
+
const valid =
|
|
24
|
+
size.width % 16 === 0 &&
|
|
25
|
+
size.height % 16 === 0 &&
|
|
26
|
+
Math.max(size.width, size.height) <= 3840 &&
|
|
27
|
+
pixels >= 655_360 &&
|
|
28
|
+
pixels <= 8_294_400 &&
|
|
29
|
+
Math.max(size.width / size.height, size.height / size.width) <= 3
|
|
30
|
+
const ratioDrift = Math.abs(size.width / size.height / (input.width / input.height) - 1)
|
|
31
|
+
return `${label} -> ${size.width}x${size.height} (${(pixels / 1e6).toFixed(2)} MP, ratio drift ${(ratioDrift * 100).toFixed(2)}%${valid ? '' : ', INVALID'})`
|
|
32
|
+
})
|
|
33
|
+
expect('\n' + results.join('\n')).toMatchInlineSnapshot(`
|
|
34
|
+
"
|
|
35
|
+
992x570 xmax -> 3792x2176 (8.25 MP, ratio drift 0.13%)
|
|
36
|
+
992x570 x2 -> 1984x1136 (2.25 MP, ratio drift 0.35%)
|
|
37
|
+
1024x1024 xmax -> 2880x2880 (8.29 MP, ratio drift 0.00%)
|
|
38
|
+
1080x1920 xmax -> 2160x3840 (8.29 MP, ratio drift 0.00%)
|
|
39
|
+
3000x1000 xmax -> 3840x1280 (4.92 MP, ratio drift 0.00%)
|
|
40
|
+
400x300 x1.5 -> 944x704 (0.66 MP, ratio drift 0.57%)
|
|
41
|
+
600x200 x2 -> 1424x480 (0.68 MP, ratio drift 1.11%)
|
|
42
|
+
4000x3000 x2: GPT Image cannot upscale a 4000x3000 image: its output is limited to 3840px per edge and 8.3 MP.
|
|
43
|
+
3100x1000 xmax: GPT Image supports aspect ratios up to 3:1. The input is 3100x1000.
|
|
44
|
+
800x600 x0.5: Scale must be greater than 1, got 0.5."
|
|
45
|
+
`)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('ChatGPT login tiles the image until ~1.6 MP per tile reaches the target', () => {
|
|
49
|
+
const cases = [
|
|
50
|
+
{ width: 992, height: 570, targetWidth: 3792 },
|
|
51
|
+
{ width: 992, height: 570, targetWidth: 1984 },
|
|
52
|
+
{ width: 1024, height: 1024, targetWidth: 2880 },
|
|
53
|
+
{ width: 300, height: 200, targetWidth: 3456 },
|
|
54
|
+
]
|
|
55
|
+
const lines = cases.map((c) => {
|
|
56
|
+
const grid = chooseGrid({ ...c, pixelsPerCall: 1536 * 1024 })
|
|
57
|
+
const tiles = planTiles({ width: c.width, height: c.height, grid })
|
|
58
|
+
const last = tiles[tiles.length - 1]!
|
|
59
|
+
const covers = last.x + last.width === c.width && last.y + last.height === c.height
|
|
60
|
+
return `${c.width}x${c.height} -> ${c.targetWidth}w: grid ${grid}, tile ${tiles[0]!.width}x${tiles[0]!.height}, covers ${covers}`
|
|
61
|
+
})
|
|
62
|
+
expect('\n' + lines.join('\n')).toMatchInlineSnapshot(`
|
|
63
|
+
"
|
|
64
|
+
992x570 -> 3792w: grid 3, tile 382x219, covers true
|
|
65
|
+
992x570 -> 1984w: grid 2, tile 551x317, covers true
|
|
66
|
+
1024x1024 -> 2880w: grid 3, tile 394x394, covers true
|
|
67
|
+
300x200 -> 3456w: grid 1, tile 300x200, covers true"
|
|
68
|
+
`)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('blendTiles maps each tile to the reference colors and keeps overlaps seamless', () => {
|
|
72
|
+
const width = 8
|
|
73
|
+
const height = 4
|
|
74
|
+
const reference = new Uint8Array(width * height * 3).map((_, i) => 100 + (i % 3) * 20)
|
|
75
|
+
// two overlapping tiles with a different global color cast each
|
|
76
|
+
const tile = (x: number, cast: number) => ({
|
|
77
|
+
x,
|
|
78
|
+
y: 0,
|
|
79
|
+
width: 5,
|
|
80
|
+
height,
|
|
81
|
+
pixels: new Uint8Array(5 * height * 3).map((_, i) => 100 + (i % 3) * 20 + cast + (i % 7)),
|
|
82
|
+
})
|
|
83
|
+
const out = blendTiles({ width, height, reference, tiles: [tile(0, 40), tile(3, -30)] })
|
|
84
|
+
const maxDiff = Math.max(...out.map((v, i) => Math.abs(v - reference[i]!)))
|
|
85
|
+
expect(maxDiff).toBeLessThanOrEqual(4)
|
|
86
|
+
|
|
87
|
+
// near-white areas push matched values past 255; they must clamp, not wrap to dark pixels
|
|
88
|
+
const bright = blendTiles({
|
|
89
|
+
width: 4,
|
|
90
|
+
height: 1,
|
|
91
|
+
reference: new Uint8Array([250, 250, 250, 255, 255, 255, 240, 240, 240, 255, 255, 255]),
|
|
92
|
+
tiles: [{ x: 0, y: 0, width: 4, height: 1, pixels: new Uint8Array([10, 10, 10, 200, 200, 200, 0, 0, 0, 255, 255, 255]) }],
|
|
93
|
+
})
|
|
94
|
+
expect(Math.min(...bright)).toBeGreaterThan(200)
|
|
95
|
+
})
|
|
96
|
+
})
|