# Film develop

> A generated image comes up like a print in the tray: a soft field of its colours, then pools of focus opening through it.

For image APIs that tell you how far along they are. While your generation runs, the frame is a developing tray: soft colour drifting in it, or, if your API streams a low-resolution preview, that preview held deep in blur and clearing a little as your progress rises. When the final image has loaded it develops like a print: a soft field of its own colours first, then pools of focus open through it on an organic front, the middle first, until the whole picture is sharp, in 1.7s. It needs no CORS, so it works with any image host.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/film-develop.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `number-roll`
- Docs and live preview: https://hairlineui.com/ui/film-develop
- Registry item (source): https://hairlineui.com/r/film-develop.json

## Usage

```tsx
import { FilmDevelop } from "@/components/film-develop";

<FilmDevelop
  src={image?.url}
  status={job.status}
  preview={job.previewUrl}
  progress={job.progress}
  alt={prompt}
  onRetry={regenerate}
  className="aspect-square w-80"
/>
```

## Polling your generation API

Start a generation, poll its status, and hand the component the real state. Any API that reports generating, ready and failed works the same way.

```tsx
"use client";
import * as React from "react";
import { FilmDevelop } from "@/components/film-develop";

type Job = { id: string; status: "generating" | "ready" | "error"; url?: string; progress?: number };

export function Generation({ prompt }: { prompt: string }) {
  const [job, setJob] = React.useState<Job | null>(null);

  async function generate() {
    const { id } = await fetch("/api/generate", { method: "POST", body: JSON.stringify({ prompt }) }).then((r) => r.json());
    setJob({ id, status: "generating" });
    const poll = window.setInterval(async () => {
      const next: Job = await fetch(`/api/generate/${id}`).then((r) => r.json());
      setJob(next);
      if (next.status !== "generating") window.clearInterval(poll);
    }, 1000);
  }

  return (
    <div className="grid gap-3">
      <FilmDevelop
        src={job?.url}
        status={job?.status ?? "generating"}
        progress={job?.progress}
        alt={prompt}
        onRetry={generate}
        className="aspect-square w-80"
      />
      <button onClick={generate}>Generate</button>
    </div>
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `src` | `string` | – | The generated image. It can arrive before or with status "ready"; the reveal waits until it has loaded and decoded. |
| `status` | `"generating" \| "ready" \| "error"` | – | Your generation’s real state. Nothing plays on a timer. |
| `progress` | `number` | – | 0 to 1, if your API reports it. Shown as a small rolling figure; without it, no number is shown. |
| `alt` | `string` | – | The image’s text alternative, usually its prompt. |
| `crossOrigin` | `"anonymous" \| "use-credentials"` | – | Set it when your image host sends CORS headers. |
| `onReady` | `() => void` | – | Called once the reveal has played, or the image is shown without one. |
| `onRetry` | `() => void` | – | Shows Try again when the generation fails. |
| `labels` | `{ generating?, ready?, failed?, retry? }` | – | Words for the progress tag, the announcements and the failure. |
| `className` | `string` | – | Size the frame here, e.g. "aspect-square w-72". |
| `preview` | `string` | – | A low-resolution preview your API streams while it works. Shown deep in blur, clearing with progress. |

## States

- **waiting**: Without a preview, two soft colour fields drift in the tray over 5.5s. With one, the preview sits scaled 110% under blur(22px), easing to blur(10px) as progress reaches 1.
- **developing**: Once the final image has decoded: a soft field of its own colours (a 14-pixel copy scaled up), a finer field fading in from 12%, and the sharp print through a noise mask whose pools open from the middle over 1.7s.
- **shown**: The plain image. onReady fires.
- **failed**: The tray with “This image couldn’t be created.” and Try again when onRetry is passed.

## What it handles

Previews from diffusion models are noisy and half-formed; shown raw they look broken, and hidden they leave people staring at a spinner.

- **Uses your preview**: A streamed preview stays deep in blur and clears with your progress, so people see it coming without the noise.
- **Develops, never pops**: The final image comes up through soft colour and then pools of focus, middle first.
- **Organic front**: Focus spreads through noise, so there are no bars or lines crossing the picture.
- **Any image host**: It only draws the image, never reads it, so it needs no CORS.
- **Honest progress**: A rolling percentage when your API reports one, and the preview’s blur follows it.
- **Failure designed**: A failed generation says so with Try again.

## Replaces

progressive jpeg, blur-up placeholder, loading spinner, fake progress bar

## Where it fits

- **Streaming generators**: Show the model’s preview frames, deep in blur, as progress rises.
- **Photo editors**: A filter or a relight developing over the photo.
- **Upscalers and restorers**: The restored photo developing out of the old one.
- **AI headshots**: Portraits arriving one by one in a studio app.

## Notes

- It follows your status: it waits while "generating", and plays only once status is "ready" and the image has loaded and decoded (img.decode), so it can never finish before the picture does. An image that was already there when the page loaded is simply shown.
- The figure has aria-busy while it waits, and a status line announces Generating, Image ready or the failure; the image keeps its alt text.
- Each frame draws the soft field, the finer field and the masked print on one canvas; the focus mask is 64 × 80 and scaled up smoothly, so its edges stay soft.
- Under reduced motion the image appears in place, with no drift while waiting.

License: MIT (https://hairlineui.com/license#components)
