Skip to content

Open source CapCut alternative.

TypeScript

feat(site): bundle a stock image catalog for Cut

David Le5f397034a1ff
diff --git a/site/public/cut-stock/animal-cat-window.jpg b/site/public/cut-stock/animal-cat-window.jpg
new file mode 100644
index 00000000..5b13020a
Binary files /dev/null and b/site/public/cut-stock/animal-cat-window.jpg differ
diff --git a/site/public/cut-stock/animal-elephants.jpg b/site/public/cut-stock/animal-elephants.jpg
new file mode 100644
index 00000000..ea668573
Binary files /dev/null and b/site/public/cut-stock/animal-elephants.jpg differ
diff --git a/site/public/cut-stock/animal-fox-snow.jpg b/site/public/cut-stock/animal-fox-snow.jpg
new file mode 100644
index 00000000..8c3fd049
Binary files /dev/null and b/site/public/cut-stock/animal-fox-snow.jpg differ
diff --git a/site/public/cut-stock/animal-horse.jpg b/site/public/cut-stock/animal-horse.jpg
new file mode 100644
index 00000000..8415c35d
Binary files /dev/null and b/site/public/cut-stock/animal-horse.jpg differ
diff --git a/site/public/cut-stock/animal-macaw.jpg b/site/public/cut-stock/animal-macaw.jpg
new file mode 100644
index 00000000..22619b4d
Binary files /dev/null and b/site/public/cut-stock/animal-macaw.jpg differ
diff --git a/site/public/cut-stock/animal-retriever-beach.jpg b/site/public/cut-stock/animal-retriever-beach.jpg
new file mode 100644
index 00000000..75a44ba8
Binary files /dev/null and b/site/public/cut-stock/animal-retriever-beach.jpg differ
diff --git a/site/public/cut-stock/anime-cherry-blossoms.jpg b/site/public/cut-stock/anime-cherry-blossoms.jpg
new file mode 100644
index 00000000..785c95fb
Binary files /dev/null and b/site/public/cut-stock/anime-cherry-blossoms.jpg differ
diff --git a/site/public/cut-stock/anime-floating-islands.jpg b/site/public/cut-stock/anime-floating-islands.jpg
new file mode 100644
index 00000000..0c4ee1a3
Binary files /dev/null and b/site/public/cut-stock/anime-floating-islands.jpg differ
diff --git a/site/public/cut-stock/anime-mecha.jpg b/site/public/cut-stock/anime-mecha.jpg
new file mode 100644
index 00000000..0a39c323
Binary files /dev/null and b/site/public/cut-stock/anime-mecha.jpg differ
diff --git a/site/public/cut-stock/anime-neon-street.jpg b/site/public/cut-stock/anime-neon-street.jpg
new file mode 100644
index 00000000..683938ab
Binary files /dev/null and b/site/public/cut-stock/anime-neon-street.jpg differ
diff --git a/site/public/cut-stock/anime-portrait.jpg b/site/public/cut-stock/anime-portrait.jpg
new file mode 100644
index 00000000..71cc67fe
Binary files /dev/null and b/site/public/cut-stock/anime-portrait.jpg differ
diff --git a/site/public/cut-stock/anime-ramen-shop.jpg b/site/public/cut-stock/anime-ramen-shop.jpg
new file mode 100644
index 00000000..a2bee1ae
Binary files /dev/null and b/site/public/cut-stock/anime-ramen-shop.jpg differ
diff --git a/site/public/cut-stock/business-boardroom.jpg b/site/public/cut-stock/business-boardroom.jpg
new file mode 100644
index 00000000..50f7feac
Binary files /dev/null and b/site/public/cut-stock/business-boardroom.jpg differ
diff --git a/site/public/cut-stock/business-desk-flatlay.jpg b/site/public/cut-stock/business-desk-flatlay.jpg
new file mode 100644
index 00000000..c6f6337a
Binary files /dev/null and b/site/public/cut-stock/business-desk-flatlay.jpg differ
diff --git a/site/public/cut-stock/business-handshake.jpg b/site/public/cut-stock/business-handshake.jpg
new file mode 100644
index 00000000..4e142952
Binary files /dev/null and b/site/public/cut-stock/business-handshake.jpg differ
diff --git a/site/public/cut-stock/business-open-office.jpg b/site/public/cut-stock/business-open-office.jpg
new file mode 100644
index 00000000..f13ce43d
Binary files /dev/null and b/site/public/cut-stock/business-open-office.jpg differ
diff --git a/site/public/cut-stock/business-presentation.jpg b/site/public/cut-stock/business-presentation.jpg
new file mode 100644
index 00000000..ff71a20d
Binary files /dev/null and b/site/public/cut-stock/business-presentation.jpg differ
diff --git a/site/public/cut-stock/business-whiteboard.jpg b/site/public/cut-stock/business-whiteboard.jpg
new file mode 100644
index 00000000..9592987d
Binary files /dev/null and b/site/public/cut-stock/business-whiteboard.jpg differ
diff --git a/site/public/cut-stock/city-aerial-grid.jpg b/site/public/cut-stock/city-aerial-grid.jpg
new file mode 100644
index 00000000..57c48d43
Binary files /dev/null and b/site/public/cut-stock/city-aerial-grid.jpg differ
diff --git a/site/public/cut-stock/city-cafe-corner.jpg b/site/public/cut-stock/city-cafe-corner.jpg
new file mode 100644
index 00000000..9d2d6915
Binary files /dev/null and b/site/public/cut-stock/city-cafe-corner.jpg differ
diff --git a/site/public/cut-stock/city-neon-crosswalk.jpg b/site/public/cut-stock/city-neon-crosswalk.jpg
new file mode 100644
index 00000000..31e61b37
Binary files /dev/null and b/site/public/cut-stock/city-neon-crosswalk.jpg differ
diff --git a/site/public/cut-stock/city-rooftop.jpg b/site/public/cut-stock/city-rooftop.jpg
new file mode 100644
index 00000000..a0d1b8bb
Binary files /dev/null and b/site/public/cut-stock/city-rooftop.jpg differ
diff --git a/site/public/cut-stock/city-skyline.jpg b/site/public/cut-stock/city-skyline.jpg
new file mode 100644
index 00000000..02547dc9
Binary files /dev/null and b/site/public/cut-stock/city-skyline.jpg differ
diff --git a/site/public/cut-stock/city-subway.jpg b/site/public/cut-stock/city-subway.jpg
new file mode 100644
index 00000000..8a11f5d5
Binary files /dev/null and b/site/public/cut-stock/city-subway.jpg differ
diff --git a/site/public/cut-stock/food-brunch.jpg b/site/public/cut-stock/food-brunch.jpg
new file mode 100644
index 00000000..4e58e30f
Binary files /dev/null and b/site/public/cut-stock/food-brunch.jpg differ
diff --git a/site/public/cut-stock/food-latte-art.jpg b/site/public/cut-stock/food-latte-art.jpg
new file mode 100644
index 00000000..55fe8ed8
Binary files /dev/null and b/site/public/cut-stock/food-latte-art.jpg differ
diff --git a/site/public/cut-stock/food-pizza.jpg b/site/public/cut-stock/food-pizza.jpg
new file mode 100644
index 00000000..17f29864
Binary files /dev/null and b/site/public/cut-stock/food-pizza.jpg differ
diff --git a/site/public/cut-stock/food-smoothie-bowl.jpg b/site/public/cut-stock/food-smoothie-bowl.jpg
new file mode 100644
index 00000000..ad6811d2
Binary files /dev/null and b/site/public/cut-stock/food-smoothie-bowl.jpg differ
diff --git a/site/public/cut-stock/food-sushi.jpg b/site/public/cut-stock/food-sushi.jpg
new file mode 100644
index 00000000..6d623beb
Binary files /dev/null and b/site/public/cut-stock/food-sushi.jpg differ
diff --git a/site/public/cut-stock/food-tacos.jpg b/site/public/cut-stock/food-tacos.jpg
new file mode 100644
index 00000000..b738f44d
Binary files /dev/null and b/site/public/cut-stock/food-tacos.jpg differ
diff --git a/site/public/cut-stock/nature-dunes.jpg b/site/public/cut-stock/nature-dunes.jpg
new file mode 100644
index 00000000..9180195d
Binary files /dev/null and b/site/public/cut-stock/nature-dunes.jpg differ
diff --git a/site/public/cut-stock/nature-misty-valley.jpg b/site/public/cut-stock/nature-misty-valley.jpg
new file mode 100644
index 00000000..16bf4c28
Binary files /dev/null and b/site/public/cut-stock/nature-misty-valley.jpg differ
diff --git a/site/public/cut-stock/nature-ocean-wave.jpg b/site/public/cut-stock/nature-ocean-wave.jpg
new file mode 100644
index 00000000..2abc04bb
Binary files /dev/null and b/site/public/cut-stock/nature-ocean-wave.jpg differ
diff --git a/site/public/cut-stock/nature-pine-fog.jpg b/site/public/cut-stock/nature-pine-fog.jpg
new file mode 100644
index 00000000..89d55936
Binary files /dev/null and b/site/public/cut-stock/nature-pine-fog.jpg differ
diff --git a/site/public/cut-stock/nature-waterfall.jpg b/site/public/cut-stock/nature-waterfall.jpg
new file mode 100644
index 00000000..65b42384
Binary files /dev/null and b/site/public/cut-stock/nature-waterfall.jpg differ
diff --git a/site/public/cut-stock/nature-wildflowers.jpg b/site/public/cut-stock/nature-wildflowers.jpg
new file mode 100644
index 00000000..15a9ce13
Binary files /dev/null and b/site/public/cut-stock/nature-wildflowers.jpg differ
diff --git a/site/public/cut-stock/tech-circuit-macro.jpg b/site/public/cut-stock/tech-circuit-macro.jpg
new file mode 100644
index 00000000..ae7611d5
Binary files /dev/null and b/site/public/cut-stock/tech-circuit-macro.jpg differ
diff --git a/site/public/cut-stock/tech-coding.jpg b/site/public/cut-stock/tech-coding.jpg
new file mode 100644
index 00000000..dcb9e265
Binary files /dev/null and b/site/public/cut-stock/tech-coding.jpg differ
diff --git a/site/public/cut-stock/tech-dashboard.jpg b/site/public/cut-stock/tech-dashboard.jpg
new file mode 100644
index 00000000..235523cc
Binary files /dev/null and b/site/public/cut-stock/tech-dashboard.jpg differ
diff --git a/site/public/cut-stock/tech-robot-arm.jpg b/site/public/cut-stock/tech-robot-arm.jpg
new file mode 100644
index 00000000..1b23eabf
Binary files /dev/null and b/site/public/cut-stock/tech-robot-arm.jpg differ
diff --git a/site/public/cut-stock/tech-server-room.jpg b/site/public/cut-stock/tech-server-room.jpg
new file mode 100644
index 00000000..da8970ec
Binary files /dev/null and b/site/public/cut-stock/tech-server-room.jpg differ
diff --git a/site/public/cut-stock/tech-vr-headset.jpg b/site/public/cut-stock/tech-vr-headset.jpg
new file mode 100644
index 00000000..db2a6385
Binary files /dev/null and b/site/public/cut-stock/tech-vr-headset.jpg differ
diff --git a/site/public/cut-stock/travel-airplane-wing.jpg b/site/public/cut-stock/travel-airplane-wing.jpg
new file mode 100644
index 00000000..64822805
Binary files /dev/null and b/site/public/cut-stock/travel-airplane-wing.jpg differ
diff --git a/site/public/cut-stock/travel-balloons.jpg b/site/public/cut-stock/travel-balloons.jpg
new file mode 100644
index 00000000..8c4081e7
Binary files /dev/null and b/site/public/cut-stock/travel-balloons.jpg differ
diff --git a/site/public/cut-stock/travel-boardwalk.jpg b/site/public/cut-stock/travel-boardwalk.jpg
new file mode 100644
index 00000000..cd474210
Binary files /dev/null and b/site/public/cut-stock/travel-boardwalk.jpg differ
diff --git a/site/public/cut-stock/travel-flatlay.jpg b/site/public/cut-stock/travel-flatlay.jpg
new file mode 100644
index 00000000..63009d4e
Binary files /dev/null and b/site/public/cut-stock/travel-flatlay.jpg differ
diff --git a/site/public/cut-stock/travel-old-town.jpg b/site/public/cut-stock/travel-old-town.jpg
new file mode 100644
index 00000000..648d4152
Binary files /dev/null and b/site/public/cut-stock/travel-old-town.jpg differ
diff --git a/site/public/cut-stock/travel-train-station.jpg b/site/public/cut-stock/travel-train-station.jpg
new file mode 100644
index 00000000..ab2ccbd6
Binary files /dev/null and b/site/public/cut-stock/travel-train-station.jpg differ
diff --git a/site/scripts/generate-stock-images.ts b/site/scripts/generate-stock-images.ts
new file mode 100644
index 00000000..ebf4aa5c
--- /dev/null
+++ b/site/scripts/generate-stock-images.ts
@@ -0,0 +1,233 @@
+// Generates the bundled Cut stock-image catalog with the same Vertex image model
+// the app uses (gemini-2.5-flash-image), then writes the typed manifest the
+// editor imports. Idempotent: items whose file already exists are skipped, so
+// re-running fills gaps or picks up new catalog entries only.
+//
+// cd site && ./node_modules/.bin/bun scripts/generate-stock-images.ts
+//
+// Needs GOOGLE_APPLICATION_CREDENTIALS_JSON (bun auto-loads site/.env) and
+// macOS `sips` to compress the raw PNGs into small JPEGs.
+
+import { execFileSync } from "node:child_process";
+import { existsSync } from "node:fs";
+import { mkdir, rm, writeFile } from "node:fs/promises";
+import os from "node:os";
+import path from "node:path";
+import { GoogleGenAI } from "@google/genai";
+import { JWT } from "google-auth-library";
+
+import type { StockAspect, StockCategory } from "../src/cut/lib/stock";
+
+interface CatalogItem {
+ id: string;
+ category: StockCategory;
+ aspect: StockAspect;
+ prompt: string;
+}
+
+const MODEL = process.env.GEMINI_IMAGE_MODEL?.trim() || "gemini-2.5-flash-image";
+const OUT_DIR = path.join(import.meta.dirname, "..", "public", "cut-stock");
+const MANIFEST = path.join(import.meta.dirname, "..", "src", "cut", "lib", "stockManifest.ts");
+const CONCURRENCY = 4;
+/** Longest image edge after compression — browse thumbnails, not print assets. */
+const MAX_EDGE = 800;
+
+const photo = (subject: string) =>
+ `Professional stock photograph: ${subject} Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.`;
+
+const anime = (subject: string) =>
+ `High-quality anime illustration: ${subject} Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.`;
+
+const CATALOG: CatalogItem[] = [
+ // Business
+ { id: "business-boardroom", category: "Business", aspect: "16:9", prompt: photo("a diverse team in a modern boardroom reviewing charts and documents spread across a large table, mid-discussion.") },
+ { id: "business-whiteboard", category: "Business", aspect: "9:16", prompt: photo("a young founder sketching a product flow on a glass whiteboard in a bright startup loft, colleagues watching.") },
+ { id: "business-handshake", category: "Business", aspect: "16:9", prompt: photo("a close-up handshake between two professionals in a sunlit office lobby, blurred glass architecture behind.") },
+ { id: "business-open-office", category: "Business", aspect: "16:9", prompt: photo("an open-plan office at golden hour, people working at standing desks, warm light streaming through tall windows.") },
+ { id: "business-presentation", category: "Business", aspect: "16:9", prompt: photo("a woman presenting quarterly growth charts on a wall screen to an attentive small team in a conference room.") },
+ { id: "business-desk-flatlay", category: "Business", aspect: "1:1", prompt: photo("a tidy flat-lay of a laptop, notebook, espresso cup, and phone on a light oak desk, viewed straight down.") },
+
+ // Nature
+ { id: "nature-misty-valley", category: "Nature", aspect: "16:9", prompt: photo("a misty mountain valley at sunrise, layered ridgelines fading into soft golden haze.") },
+ { id: "nature-waterfall", category: "Nature", aspect: "16:9", prompt: photo("a tropical waterfall pouring into a clear jungle pool, lush ferns and volcanic rock around it.") },
+ { id: "nature-dunes", category: "Nature", aspect: "16:9", prompt: photo("rippled sand dunes at dusk, long shadows and a deep orange-to-violet gradient sky.") },
+ { id: "nature-pine-fog", category: "Nature", aspect: "9:16", prompt: photo("tall pine trees rising through morning fog, shot upward from the forest floor.") },
+ { id: "nature-ocean-wave", category: "Nature", aspect: "16:9", prompt: photo("a turquoise ocean wave curling and catching backlight, spray frozen mid-air.") },
+ { id: "nature-wildflowers", category: "Nature", aspect: "1:1", prompt: photo("a macro of wildflowers in a summer meadow, one poppy in crisp focus against a creamy bokeh field.") },
+
+ // Travel
+ { id: "travel-train-station", category: "Travel", aspect: "16:9", prompt: photo("two backpackers walking through a grand old train station, a vintage orange train waiting on the platform.") },
+ { id: "travel-old-town", category: "Travel", aspect: "9:16", prompt: photo("a narrow cobblestone alley in a European old town, flower boxes on shutters, warm evening lanterns.") },
+ { id: "travel-airplane-wing", category: "Travel", aspect: "16:9", prompt: photo("an airplane wing over a sea of sunset clouds, window-seat perspective.") },
+ { id: "travel-boardwalk", category: "Travel", aspect: "16:9", prompt: photo("a wooden boardwalk lined with palm trees leading to a white-sand beach and clear shallow water.") },
+ { id: "travel-balloons", category: "Travel", aspect: "16:9", prompt: photo("dozens of hot-air balloons drifting over a rocky valley at dawn, soft pastel sky.") },
+ { id: "travel-flatlay", category: "Travel", aspect: "1:1", prompt: photo("a flat-lay of a passport, film camera, sunglasses, and a paper map with a marked route, viewed from above.") },
+
+ // City
+ { id: "city-skyline", category: "City", aspect: "16:9", prompt: photo("a modern city skyline across the water at blue hour, glass towers reflecting the last light.") },
+ { id: "city-neon-crosswalk", category: "City", aspect: "9:16", prompt: photo("a rainy neon-lit crosswalk at night, umbrellas and reflections on wet asphalt.") },
+ { id: "city-rooftop", category: "City", aspect: "16:9", prompt: photo("a rooftop terrace view over downtown at sunset, string lights in the foreground.") },
+ { id: "city-subway", category: "City", aspect: "16:9", prompt: photo("a subway train arriving in motion blur while commuters wait on the platform.") },
+ { id: "city-cafe-corner", category: "City", aspect: "16:9", prompt: photo("a sidewalk café on a leafy street corner, bicycles parked outside, morning light.") },
+ { id: "city-aerial-grid", category: "City", aspect: "1:1", prompt: photo("a straight-down aerial of a busy city intersection, crosswalk stripes and tiny cars forming a clean grid.") },
+
+ // Technology
+ { id: "tech-coding", category: "Technology", aspect: "16:9", prompt: photo("a developer at a dual-monitor setup writing code in a dim room, screen glow on their face.") },
+ { id: "tech-server-room", category: "Technology", aspect: "16:9", prompt: photo("a long server-room aisle with racks of blinking status lights fading into the distance.") },
+ { id: "tech-circuit-macro", category: "Technology", aspect: "1:1", prompt: photo("a macro of a circuit board, gold traces and a CPU die in sharp focus, shallow depth of field.") },
+ { id: "tech-robot-arm", category: "Technology", aspect: "16:9", prompt: photo("an industrial robot arm assembling components on a clean production line, cool white lighting.") },
+ { id: "tech-vr-headset", category: "Technology", aspect: "9:16", prompt: photo("a person wearing a VR headset reaching out, lit by soft violet and cyan studio light.") },
+ { id: "tech-dashboard", category: "Technology", aspect: "16:9", prompt: photo("a large monitor showing a clean analytics dashboard with charts, a blurred office behind it.") },
+
+ // Anime
+ { id: "anime-neon-street", category: "Anime", aspect: "9:16", prompt: anime("a rain-slicked neon city street at night, a figure with a glowing umbrella walking toward the viewer.") },
+ { id: "anime-cherry-blossoms", category: "Anime", aspect: "16:9", prompt: anime("a student on a hilltop path under falling cherry blossoms, a town and sea far below.") },
+ { id: "anime-mecha", category: "Anime", aspect: "16:9", prompt: anime("a giant mecha standing guard over a futuristic city at sunset, clouds parting dramatically.") },
+ { id: "anime-ramen-shop", category: "Anime", aspect: "16:9", prompt: anime("a cozy late-night ramen shop interior, steam rising from bowls, warm lantern light.") },
+ { id: "anime-floating-islands", category: "Anime", aspect: "16:9", prompt: anime("a fantasy landscape of floating islands with waterfalls spilling into the sky, airships drifting between them.") },
+ { id: "anime-portrait", category: "Anime", aspect: "1:1", prompt: anime("a close-up portrait of a silver-haired adventurer with bright green eyes, wind-blown hair, golden-hour light.") },
+
+ // Animal
+ { id: "animal-retriever-beach", category: "Animal", aspect: "16:9", prompt: photo("a golden retriever sprinting along a beach at sunset, sand kicking up, ears flying.") },
+ { id: "animal-cat-window", category: "Animal", aspect: "1:1", prompt: photo("a tabby cat sitting in soft window light, dust motes in the sunbeam.") },
+ { id: "animal-fox-snow", category: "Animal", aspect: "16:9", prompt: photo("a red fox stepping through fresh snow in a quiet forest, breath visible in the cold air.") },
+ { id: "animal-macaw", category: "Animal", aspect: "9:16", prompt: photo("a scarlet macaw perched on a branch, vivid red and blue feathers against deep green jungle bokeh.") },
+ { id: "animal-elephants", category: "Animal", aspect: "16:9", prompt: photo("a family of elephants at a watering hole at dusk, golden dust in the air.") },
+ { id: "animal-horse", category: "Animal", aspect: "16:9", prompt: photo("a chestnut horse galloping through a misty field at dawn, mane streaming.") },
+
+ // Food & Drink
+ { id: "food-brunch", category: "Food & Drink", aspect: "16:9", prompt: photo("a generous brunch spread on a rustic table: pancakes, fruit, coffee, and fresh juice, soft morning light.") },
+ { id: "food-latte-art", category: "Food & Drink", aspect: "1:1", prompt: photo("a close-up of latte art in a ceramic cup on a marble counter, steam curling upward.") },
+ { id: "food-sushi", category: "Food & Drink", aspect: "16:9", prompt: photo("an elegant sushi platter on dark slate, nigiri and rolls arranged with pickled ginger and wasabi.") },
+ { id: "food-tacos", category: "Food & Drink", aspect: "16:9", prompt: photo("three street tacos with charred meat, cilantro, and lime on a paper-lined tray, market lights behind.") },
+ { id: "food-smoothie-bowl", category: "Food & Drink", aspect: "9:16", prompt: photo("a vibrant berry smoothie bowl topped with granola, banana, and chia seeds, shot from a high angle.") },
+ { id: "food-pizza", category: "Food & Drink", aspect: "16:9", prompt: photo("a wood-fired margherita pizza fresh from the oven, bubbling mozzarella and basil, embers glowing behind.") },
+];
+
+function makeClient(): { client: GoogleGenAI; project: string } {
+ const raw = process.env.GOOGLE_APPLICATION_CREDENTIALS_JSON?.trim();
+ if (!raw) throw new Error("GOOGLE_APPLICATION_CREDENTIALS_JSON is not set (run from site/ so bun loads .env).");
+ const creds = JSON.parse(raw) as { project_id?: string; client_email?: string; private_key?: string; private_key_id?: string };
+ if (!creds.project_id || !creds.client_email || !creds.private_key) {
+ throw new Error("Service account JSON is missing project_id/client_email/private_key.");
+ }
+ const authClient = new JWT({
+ email: creds.client_email,
+ key: creds.private_key,
+ keyId: creds.private_key_id,
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
+ });
+ const client = new GoogleGenAI({
+ vertexai: true,
+ location: "global",
+ project: creds.project_id,
+ googleAuthOptions: { authClient },
+ });
+ return { client, project: creds.project_id };
+}
+
+const aspectHint: Record<StockAspect, string> = {
+ "16:9": "16:9 widescreen",
+ "9:16": "9:16 vertical",
+ "1:1": "1:1 square",
+};
+
+async function generateOne(client: GoogleGenAI, item: CatalogItem): Promise<Buffer> {
+ const contents = [
+ {
+ role: "user",
+ parts: [{ text: `${item.prompt}\n\nCompose the image in a ${aspectHint[item.aspect]} frame.` }],
+ },
+ ];
+ // imageConfig pins the output aspect on models that honor it; the prompt line
+ // above steers the rest. Fall back to prompt-only if the field is rejected.
+ let response;
+ try {
+ response = await client.models.generateContent({
+ model: MODEL,
+ contents,
+ config: {
+ responseModalities: ["IMAGE", "TEXT"],
+ imageConfig: { aspectRatio: item.aspect },
+ } as Record<string, unknown>,
+ });
+ } catch {
+ response = await client.models.generateContent({
+ model: MODEL,
+ contents,
+ config: { responseModalities: ["IMAGE", "TEXT"] },
+ });
+ }
+ const parts = response.candidates?.[0]?.content?.parts ?? [];
+ for (const part of parts) {
+ const data = part.inlineData?.data;
+ if (data) return Buffer.from(data, "base64");
+ }
+ throw new Error("no image in response");
+}
+
+function compress(rawPng: string, outJpg: string) {
+ execFileSync("sips", ["-Z", String(MAX_EDGE), "-s", "format", "jpeg", "-s", "formatOptions", "82", rawPng, "--out", outJpg], {
+ stdio: "ignore",
+ });
+}
+
+async function writeManifest(done: Set<string>) {
+ const entries = CATALOG.filter((c) => done.has(c.id)).map((c) => ({
+ id: c.id,
+ category: c.category,
+ prompt: c.prompt,
+ aspect: c.aspect,
+ file: `/cut-stock/${c.id}.jpg`,
+ }));
+ const body = `// Generated by scripts/generate-stock-images.ts — do not edit by hand.
+import type { StockImage } from "./stock";
+
+export const STOCK_IMAGES: StockImage[] = ${JSON.stringify(entries, null, 2)};
+`;
+ await writeFile(MANIFEST, body);
+}
+
+async function main() {
+ const { client, project } = makeClient();
+ await mkdir(OUT_DIR, { recursive: true });
+ const tmp = path.join(os.tmpdir(), `cut-stock-${process.pid}`);
+ await mkdir(tmp, { recursive: true });
+
+ const done = new Set<string>(CATALOG.filter((c) => existsSync(path.join(OUT_DIR, `${c.id}.jpg`))).map((c) => c.id));
+ const todo = CATALOG.filter((c) => !done.has(c.id));
+ console.log(`model=${MODEL} project=${project} existing=${done.size} generating=${todo.length}`);
+
+ let failed = 0;
+ const queue = [...todo];
+ const worker = async () => {
+ for (let item = queue.shift(); item; item = queue.shift()) {
+ for (let attempt = 1; ; attempt++) {
+ try {
+ const png = await generateOne(client, item);
+ const raw = path.join(tmp, `${item.id}.png`);
+ await writeFile(raw, png);
+ compress(raw, path.join(OUT_DIR, `${item.id}.jpg`));
+ done.add(item.id);
+ console.log(`✓ ${item.id} (${item.aspect})`);
+ break;
+ } catch (e) {
+ if (attempt >= 2) {
+ failed++;
+ console.error(`✗ ${item.id}: ${e instanceof Error ? e.message : e}`);
+ break;
+ }
+ console.warn(`retrying ${item.id}…`);
+ }
+ }
+ }
+ };
+ await Promise.all(Array.from({ length: CONCURRENCY }, worker));
+ await rm(tmp, { recursive: true, force: true });
+
+ await writeManifest(done);
+ console.log(`manifest: ${done.size}/${CATALOG.length} images${failed ? `, ${failed} failed` : ""}`);
+ if (failed) process.exitCode = 1;
+}
+
+await main();
diff --git a/site/src/cut/lib/stock.ts b/site/src/cut/lib/stock.ts
new file mode 100644
index 00000000..afa18f51
--- /dev/null
+++ b/site/src/cut/lib/stock.ts
@@ -0,0 +1,36 @@
+// The bundled stock-image catalog: AI-generated stills that ship with the site
+// (files under public/cut-stock, manifest in stockManifest.ts). Each entry keeps
+// the exact prompt that produced it — clicking a stock image copies that prompt
+// into the generate flyover for the user to edit and re-render on their account.
+// Regenerate or extend the set with `bun scripts/generate-stock-images.ts`.
+
+export type StockAspect = "16:9" | "9:16" | "1:1";
+
+export interface StockImage {
+ id: string;
+ category: StockCategory;
+ /** The generation prompt, saved verbatim — the editable starting point. */
+ prompt: string;
+ aspect: StockAspect;
+ /** Site-relative image URL (under /cut-stock/). */
+ file: string;
+}
+
+export const STOCK_CATEGORIES = [
+ "Business",
+ "Nature",
+ "Travel",
+ "City",
+ "Technology",
+ "Anime",
+ "Animal",
+ "Food & Drink",
+] as const;
+
+export type StockCategory = (typeof STOCK_CATEGORIES)[number];
+
+export const STOCK_ASPECT_LABEL: Record<StockAspect, string> = {
+ "16:9": "Landscape (16:9)",
+ "9:16": "Portrait (9:16)",
+ "1:1": "Square (1:1)",
+};
diff --git a/site/src/cut/lib/stockManifest.ts b/site/src/cut/lib/stockManifest.ts
new file mode 100644
index 00000000..1ef957af
--- /dev/null
+++ b/site/src/cut/lib/stockManifest.ts
@@ -0,0 +1,341 @@
+// Generated by scripts/generate-stock-images.ts — do not edit by hand.
+import type { StockImage } from "./stock";
+
+export const STOCK_IMAGES: StockImage[] = [
+ {
+ "id": "business-boardroom",
+ "category": "Business",
+ "prompt": "Professional stock photograph: a diverse team in a modern boardroom reviewing charts and documents spread across a large table, mid-discussion. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/business-boardroom.jpg"
+ },
+ {
+ "id": "business-whiteboard",
+ "category": "Business",
+ "prompt": "Professional stock photograph: a young founder sketching a product flow on a glass whiteboard in a bright startup loft, colleagues watching. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/business-whiteboard.jpg"
+ },
+ {
+ "id": "business-handshake",
+ "category": "Business",
+ "prompt": "Professional stock photograph: a close-up handshake between two professionals in a sunlit office lobby, blurred glass architecture behind. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/business-handshake.jpg"
+ },
+ {
+ "id": "business-open-office",
+ "category": "Business",
+ "prompt": "Professional stock photograph: an open-plan office at golden hour, people working at standing desks, warm light streaming through tall windows. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/business-open-office.jpg"
+ },
+ {
+ "id": "business-presentation",
+ "category": "Business",
+ "prompt": "Professional stock photograph: a woman presenting quarterly growth charts on a wall screen to an attentive small team in a conference room. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/business-presentation.jpg"
+ },
+ {
+ "id": "business-desk-flatlay",
+ "category": "Business",
+ "prompt": "Professional stock photograph: a tidy flat-lay of a laptop, notebook, espresso cup, and phone on a light oak desk, viewed straight down. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/business-desk-flatlay.jpg"
+ },
+ {
+ "id": "nature-misty-valley",
+ "category": "Nature",
+ "prompt": "Professional stock photograph: a misty mountain valley at sunrise, layered ridgelines fading into soft golden haze. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/nature-misty-valley.jpg"
+ },
+ {
+ "id": "nature-waterfall",
+ "category": "Nature",
+ "prompt": "Professional stock photograph: a tropical waterfall pouring into a clear jungle pool, lush ferns and volcanic rock around it. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/nature-waterfall.jpg"
+ },
+ {
+ "id": "nature-dunes",
+ "category": "Nature",
+ "prompt": "Professional stock photograph: rippled sand dunes at dusk, long shadows and a deep orange-to-violet gradient sky. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/nature-dunes.jpg"
+ },
+ {
+ "id": "nature-pine-fog",
+ "category": "Nature",
+ "prompt": "Professional stock photograph: tall pine trees rising through morning fog, shot upward from the forest floor. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/nature-pine-fog.jpg"
+ },
+ {
+ "id": "nature-ocean-wave",
+ "category": "Nature",
+ "prompt": "Professional stock photograph: a turquoise ocean wave curling and catching backlight, spray frozen mid-air. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/nature-ocean-wave.jpg"
+ },
+ {
+ "id": "nature-wildflowers",
+ "category": "Nature",
+ "prompt": "Professional stock photograph: a macro of wildflowers in a summer meadow, one poppy in crisp focus against a creamy bokeh field. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/nature-wildflowers.jpg"
+ },
+ {
+ "id": "travel-train-station",
+ "category": "Travel",
+ "prompt": "Professional stock photograph: two backpackers walking through a grand old train station, a vintage orange train waiting on the platform. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/travel-train-station.jpg"
+ },
+ {
+ "id": "travel-old-town",
+ "category": "Travel",
+ "prompt": "Professional stock photograph: a narrow cobblestone alley in a European old town, flower boxes on shutters, warm evening lanterns. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/travel-old-town.jpg"
+ },
+ {
+ "id": "travel-airplane-wing",
+ "category": "Travel",
+ "prompt": "Professional stock photograph: an airplane wing over a sea of sunset clouds, window-seat perspective. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/travel-airplane-wing.jpg"
+ },
+ {
+ "id": "travel-boardwalk",
+ "category": "Travel",
+ "prompt": "Professional stock photograph: a wooden boardwalk lined with palm trees leading to a white-sand beach and clear shallow water. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/travel-boardwalk.jpg"
+ },
+ {
+ "id": "travel-balloons",
+ "category": "Travel",
+ "prompt": "Professional stock photograph: dozens of hot-air balloons drifting over a rocky valley at dawn, soft pastel sky. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/travel-balloons.jpg"
+ },
+ {
+ "id": "travel-flatlay",
+ "category": "Travel",
+ "prompt": "Professional stock photograph: a flat-lay of a passport, film camera, sunglasses, and a paper map with a marked route, viewed from above. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/travel-flatlay.jpg"
+ },
+ {
+ "id": "city-skyline",
+ "category": "City",
+ "prompt": "Professional stock photograph: a modern city skyline across the water at blue hour, glass towers reflecting the last light. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/city-skyline.jpg"
+ },
+ {
+ "id": "city-neon-crosswalk",
+ "category": "City",
+ "prompt": "Professional stock photograph: a rainy neon-lit crosswalk at night, umbrellas and reflections on wet asphalt. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/city-neon-crosswalk.jpg"
+ },
+ {
+ "id": "city-rooftop",
+ "category": "City",
+ "prompt": "Professional stock photograph: a rooftop terrace view over downtown at sunset, string lights in the foreground. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/city-rooftop.jpg"
+ },
+ {
+ "id": "city-subway",
+ "category": "City",
+ "prompt": "Professional stock photograph: a subway train arriving in motion blur while commuters wait on the platform. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/city-subway.jpg"
+ },
+ {
+ "id": "city-cafe-corner",
+ "category": "City",
+ "prompt": "Professional stock photograph: a sidewalk café on a leafy street corner, bicycles parked outside, morning light. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/city-cafe-corner.jpg"
+ },
+ {
+ "id": "city-aerial-grid",
+ "category": "City",
+ "prompt": "Professional stock photograph: a straight-down aerial of a busy city intersection, crosswalk stripes and tiny cars forming a clean grid. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/city-aerial-grid.jpg"
+ },
+ {
+ "id": "tech-coding",
+ "category": "Technology",
+ "prompt": "Professional stock photograph: a developer at a dual-monitor setup writing code in a dim room, screen glow on their face. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/tech-coding.jpg"
+ },
+ {
+ "id": "tech-server-room",
+ "category": "Technology",
+ "prompt": "Professional stock photograph: a long server-room aisle with racks of blinking status lights fading into the distance. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/tech-server-room.jpg"
+ },
+ {
+ "id": "tech-circuit-macro",
+ "category": "Technology",
+ "prompt": "Professional stock photograph: a macro of a circuit board, gold traces and a CPU die in sharp focus, shallow depth of field. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/tech-circuit-macro.jpg"
+ },
+ {
+ "id": "tech-robot-arm",
+ "category": "Technology",
+ "prompt": "Professional stock photograph: an industrial robot arm assembling components on a clean production line, cool white lighting. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/tech-robot-arm.jpg"
+ },
+ {
+ "id": "tech-vr-headset",
+ "category": "Technology",
+ "prompt": "Professional stock photograph: a person wearing a VR headset reaching out, lit by soft violet and cyan studio light. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/tech-vr-headset.jpg"
+ },
+ {
+ "id": "tech-dashboard",
+ "category": "Technology",
+ "prompt": "Professional stock photograph: a large monitor showing a clean analytics dashboard with charts, a blurred office behind it. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/tech-dashboard.jpg"
+ },
+ {
+ "id": "anime-neon-street",
+ "category": "Anime",
+ "prompt": "High-quality anime illustration: a rain-slicked neon city street at night, a figure with a glowing umbrella walking toward the viewer. Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.",
+ "aspect": "9:16",
+ "file": "/cut-stock/anime-neon-street.jpg"
+ },
+ {
+ "id": "anime-cherry-blossoms",
+ "category": "Anime",
+ "prompt": "High-quality anime illustration: a student on a hilltop path under falling cherry blossoms, a town and sea far below. Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.",
+ "aspect": "16:9",
+ "file": "/cut-stock/anime-cherry-blossoms.jpg"
+ },
+ {
+ "id": "anime-mecha",
+ "category": "Anime",
+ "prompt": "High-quality anime illustration: a giant mecha standing guard over a futuristic city at sunset, clouds parting dramatically. Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.",
+ "aspect": "16:9",
+ "file": "/cut-stock/anime-mecha.jpg"
+ },
+ {
+ "id": "anime-ramen-shop",
+ "category": "Anime",
+ "prompt": "High-quality anime illustration: a cozy late-night ramen shop interior, steam rising from bowls, warm lantern light. Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.",
+ "aspect": "16:9",
+ "file": "/cut-stock/anime-ramen-shop.jpg"
+ },
+ {
+ "id": "anime-floating-islands",
+ "category": "Anime",
+ "prompt": "High-quality anime illustration: a fantasy landscape of floating islands with waterfalls spilling into the sky, airships drifting between them. Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.",
+ "aspect": "16:9",
+ "file": "/cut-stock/anime-floating-islands.jpg"
+ },
+ {
+ "id": "anime-portrait",
+ "category": "Anime",
+ "prompt": "High-quality anime illustration: a close-up portrait of a silver-haired adventurer with bright green eyes, wind-blown hair, golden-hour light. Clean line art, vibrant cel shading, detailed background, cinematic composition. No text, no watermarks.",
+ "aspect": "1:1",
+ "file": "/cut-stock/anime-portrait.jpg"
+ },
+ {
+ "id": "animal-retriever-beach",
+ "category": "Animal",
+ "prompt": "Professional stock photograph: a golden retriever sprinting along a beach at sunset, sand kicking up, ears flying. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/animal-retriever-beach.jpg"
+ },
+ {
+ "id": "animal-cat-window",
+ "category": "Animal",
+ "prompt": "Professional stock photograph: a tabby cat sitting in soft window light, dust motes in the sunbeam. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/animal-cat-window.jpg"
+ },
+ {
+ "id": "animal-fox-snow",
+ "category": "Animal",
+ "prompt": "Professional stock photograph: a red fox stepping through fresh snow in a quiet forest, breath visible in the cold air. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/animal-fox-snow.jpg"
+ },
+ {
+ "id": "animal-macaw",
+ "category": "Animal",
+ "prompt": "Professional stock photograph: a scarlet macaw perched on a branch, vivid red and blue feathers against deep green jungle bokeh. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/animal-macaw.jpg"
+ },
+ {
+ "id": "animal-elephants",
+ "category": "Animal",
+ "prompt": "Professional stock photograph: a family of elephants at a watering hole at dusk, golden dust in the air. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/animal-elephants.jpg"
+ },
+ {
+ "id": "animal-horse",
+ "category": "Animal",
+ "prompt": "Professional stock photograph: a chestnut horse galloping through a misty field at dawn, mane streaming. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/animal-horse.jpg"
+ },
+ {
+ "id": "food-brunch",
+ "category": "Food & Drink",
+ "prompt": "Professional stock photograph: a generous brunch spread on a rustic table: pancakes, fruit, coffee, and fresh juice, soft morning light. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/food-brunch.jpg"
+ },
+ {
+ "id": "food-latte-art",
+ "category": "Food & Drink",
+ "prompt": "Professional stock photograph: a close-up of latte art in a ceramic cup on a marble counter, steam curling upward. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "1:1",
+ "file": "/cut-stock/food-latte-art.jpg"
+ },
+ {
+ "id": "food-sushi",
+ "category": "Food & Drink",
+ "prompt": "Professional stock photograph: an elegant sushi platter on dark slate, nigiri and rolls arranged with pickled ginger and wasabi. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/food-sushi.jpg"
+ },
+ {
+ "id": "food-tacos",
+ "category": "Food & Drink",
+ "prompt": "Professional stock photograph: three street tacos with charred meat, cilantro, and lime on a paper-lined tray, market lights behind. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/food-tacos.jpg"
+ },
+ {
+ "id": "food-smoothie-bowl",
+ "category": "Food & Drink",
+ "prompt": "Professional stock photograph: a vibrant berry smoothie bowl topped with granola, banana, and chia seeds, shot from a high angle. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "9:16",
+ "file": "/cut-stock/food-smoothie-bowl.jpg"
+ },
+ {
+ "id": "food-pizza",
+ "category": "Food & Drink",
+ "prompt": "Professional stock photograph: a wood-fired margherita pizza fresh from the oven, bubbling mozzarella and basil, embers glowing behind. Natural lighting, shallow depth of field, sharp focus, realistic color grading. No text, no watermarks, no logos.",
+ "aspect": "16:9",
+ "file": "/cut-stock/food-pizza.jpg"
+ }
+];