Skip to Content
gentlemans-stack
ReferenceTools

image-gen-tools

The one implementation of store and website images for a Flutter app: screen capture, the App Store and Play screenshot cards (iPhone, iPad, Mac, Play phone, Play tablet), the Play feature graphic, the store listing icons and the website's favicons, share card and screenshots. Every image is HTML/CSS rendered in Playwright's Chromium (or resized with sharp), so re-run a command after a UI or brand change.

API

This package exports no library API. It is a CLI; its commands are under Commands. The tool is an Nx project in tools/image-gen-tools and runs as plain Node (type stripping runs .ts files directly, no build step). The reasoning is in docs/stack.md.

Before you start

You needWhereNotes
Configapps/<app>/image-gen.config.jsonSchema and an example: Config. todo-mobile has one.
App icon PNGsapps/<app>/assets/icon/light.png, dark.pngMade by flutter-brand-icons; read only here.
Logo SVGapps/<app>/assets/icon/source/logo.svgOne flat black fill, tight crop. website draws the favicons from it.
Capture test filesintegration_test/capture_test.dart, test_driver/integration_test.dartWritten by the mobile-app generator (a later step).
Simulators, MacBooted iPhone and iPad simulators; Xcode; Fluttercapture drives each device in capture.devices.
Chromiumpnpm nx run image-gen-tools:install-browser (once)Not run by any other target.

--app=<name> picks the app under apps/; it can be left out while only one app has a config.

Config

The tool holds no app data. Everything app-specific is in apps/<app>/image-gen.config.json, validated with Zod in lib/config.ts (screens, copy, card order, store targets, capture defines, website output). Colours and the font are design-token names: lib/tokens.ts reads their values from ui-libs/design-tokens/src/tokens.json and embeds the font's bundled files from ui-libs/design-tokens/fonts, so a render never reaches Google Fonts.

apps/<app>/image-gen.config.json is validated by lib/config.ts. Paths are app-relative; colour values are token names (defaults shown except accent, which is required); font is a key under font in tokens.json. Each store target needs its device in capture.devices.

{
  "app": { "brandName": "Todo", "icon": { "dark": "assets/icon/dark.png", "light": "assets/icon/light.png", "logo": "assets/icon/source/logo.svg" } },
  "brand": {
    "colors": { "accent": "info", "background": "background", "body": "textSecondary", "surface": "surface", "text": "text" },
    "font": "sans"
  },
  "capture": {
    "dartDefines": { "DEMO": "true" },
    "devices": ["iphone", "ipad", "macos"],
    "screens": [{ "name": "home", "route": "/" }, { "action": "openTask", "name": "task", "route": "/", "waitMs": 2000 }]
  },
  "featureGraphic": { "captures": ["home", "task"], "title": "Plan the day\n*one list at a time.*" },
  "store": {
    "cards": [
      { "body": "Add tasks and check them off.", "capture": "home", "cover": true, "name": "cover", "title": "Plan the day\n*one list at a time.*", "variant": "center" },
      { "body": "Tap a task to finish it.", "bodyDesktop": "Click a task to finish it.", "callout": { "left": 0.2, "rect": [0.04, 0.36, 0.92, 0.12], "top": 0.6, "width": 0.76 }, "capture": "task", "name": "tasks", "skip": ["android"], "title": "Add a task,\n*check it off.*", "variant": "left" },
      { "body": "The same screens in both themes.", "capture": "home", "name": "themes", "pair": true, "title": "Light and dark,\n*on every screen.*", "variant": "center" }
    ],
    "targets": ["ios", "android", "ipad", "macos"]
  },
  "website": {
    "publicDir": "../todo-ui/public",
    "shareCard": { "title": "Plan the day, one list at a time." },
    "shots": [{ "capture": "home", "device": "iphone", "width": 640 }, { "capture": "home", "device": "macos", "width": 1800 }]
  }
}

YouTube

youtube makes the channel's profile picture (800x800) and video watermark (150x150) from app.icon.light, with no config. The banner (2048x1152) needs youtube.banner: { "title": "...", "captures": ["<screen>", "<screen>"] }, one or two iPhone screens. Only the centre 1235x338 px shows on phones, so the title sits there and the phones stay at the edges.

Capture

capture passes the screen list as --dart-define=CAPTURE_PLAN=<json> ([{ action?, name, route, waitMs? }], copied from capture.screens), every capture.dartDefines entry, and the output folder in the CAPTURE_DIR environment variable. The test opens each route and writes <name>.png then dark/<name>.png there. A screen's action names an entry in integration_test/capture_actions.dart. Demo data is app code behind a capture.dartDefines flag, never in the tool.

On the Mac, Flutter cannot screenshot, so the run adds --dart-define=CAPTURE_DESKTOP=true; the test prints CAPTURE_SHOT <name> and holds still while the tool resizes the window to 1440x900 pt and grabs it with screencapture. That needs Screen Recording permission (and Accessibility for the resize) for the terminal. The window is found by PRODUCT_NAME in macos/Runner/Configs/AppInfo.xcconfig. With several simulators of one kind booted, the first is used.

Cards

Cards render in array order, alternating a dark and a light ground by position. Keys: name, title (\n breaks a line, *word* is the accent colour), body (optional bodyTablet, bodyDesktop), capture (a screen name), variant (left, center, right), and the optional cover (brand lockup, two devices), pair (both themes), callout (a crop of the capture in front of a phone; rect is [x, y, w, h] of the capture, left/top/width of the canvas, all fractions) and skip (store targets). The layouts are a fixed set in lib/store-design.ts: a new layout is a change there for every app, not a per-app template.

TargetShowsOutput
iosiPhone captures, iPhone frame1320x2868
ios-6.3iPhone captures, iPhone frame (the App Store's 6.1"/6.3" slot)1206x2622
androidiPhone captures, CSS Android phone frame1080x1920
ios-foldiPhone Duo captures, open Duo frame, closed Duo on some cards (the App Store iPhone Duo slot)2007x2853
ipadiPad captures, iPad frame2064x2752
android-tabletiPad captures, CSS tablet frame2064x2752
macosMac captures, window frame2880x1800

App Store header

With an appleHeader entry ({ "title": "...", "captures": { "iphone": "<screen>", "ipad": "<screen>", "macos": "<screen>" } }, any subset of devices, each in capture.devices), store also writes the App Store Connect product page header in both sizes. apple-header/apple-header-21x9.png (3840x1646), apple-header-16x9.png (5244x2950, which also fits the search result slot) and apple-search-3x2.png (3840x2560, the search result slot). The title sits centred over the devices, the Mac in the middle in the light theme and the tablet and phone in front of its corners in the dark one (lib/header.ts). Apple crops these per device and orientation, so keep the title short. Both are opaque RGB.

Each target needs its device (iphone, ipad, macos) in capture.devices. The feature graphic (1024x500) and share card (1200x630) are flattened to opaque RGB, like every card; the App Store icon (1024) has no alpha, the Play icon (512) has.

Not covered

  • Android video (record-android.ts) stays in mqtizer.
  • Brand icons and splash: flutter-brand-icons owns them.
  • The capture test files (mobile-app generator) and the skills that run this tool.

Commands

Run from the repo root as pnpm nx run image-gen-tools:<command> [-- --app=<name>]. The normal loop is capture, then store, website and youtube.

pnpm nx run image-gen-tools:install-browser   # once: download Playwright's Chromium (writes Playwright's cache)
pnpm nx run image-gen-tools:capture           # optionally name devices (iphone ipad duo macos): run the capture test with flutter drive on each booted simulator and on this Mac, light then dark (writes dist/<app>/captures/<device>/[dark/]<screen>.png)
pnpm nx run image-gen-tools:store             # optionally name targets to render only their cards: cards for each store.targets entry, the feature graphic, the App Store header (with appleHeader) and the listing icons (writes dist/<app>/store/)
pnpm nx run image-gen-tools:website           # favicon.svg, favicon.ico, apple-touch-icon.png, og-default.png and shots/<device>-<screen>-<light|dark>.webp (writes website.publicDir)
pnpm nx run image-gen-tools:youtube           # profile-picture-800.png, watermark-150.png and, with youtube.banner, banner-2048x1152.png, from lib/youtube.ts (writes dist/<app>/youtube/)
pnpm nx run image-gen-tools:cut-devices       # optionally name entries: rebuild the device frames from the photos in assets/source/ (overlay PNG, screen mask, devices.json); needed only when a photo or its entry in cut-devices.ts changes (writes assets/)
pnpm nx run image-gen-tools:typecheck         # type-check the tool

On this page