# Free slide conversion

The [LinkedIn carousel maker](https://flaghand.com/linkedin-carousel-maker) and [TikTok slideshow maker](https://flaghand.com/tiktok-slideshow-maker) also have stateless machine interfaces. They use the same text layout, fonts, photo decoder, slide renderer, lossless PDF writer and PNG ZIP writer as the browser tools. No workspace, account, subscription, media upload or saved draft is needed.

## Choose where conversion runs

- **Browser makers:** words and photos stay in the page's memory. They are not sent to the API. Their existing browser-local behavior is unchanged.
- **Local CLI / local stdio MCP:** conversion runs on your machine with the installed CLI's bundled renderer, WebAssembly and fonts. After installation, conversion needs no network and reads no workspace token. Inputs and outputs stay local unless you send them elsewhere yourself. An MCP host/model may independently receive tool arguments and results under that host's own data policies.
- **Hosted API / remote MCP:** your words, slide JSON and base64 photo bytes go to Flaghand's server for conversion. The conversion does not save them to a workspace, database or media storage, or send them to a social platform or model provider. The answer carries the editable document, warnings and exported files. This is not the browser-local path.

Exporting is not posting. To publish later, upload the resulting files to a workspace, draft and schedule as usual. No interface here schedules, connects accounts or posts. Conversion is not a platform eligibility check: LinkedIn's 100 MB document upload rule and TikTok's account, photo-post and owner-consent requirements still apply when publishing.

## Local CLI and stdio MCP

Install the [hosted CLI](https://app.flaghand.com/docs/setup#shells-including-windows) once. From a checkout, run `node cli/bin/flaghand.mjs` in place of `flaghand`.

Save `input.json`:

```json
{"text":"Carousels people finish.\n\nOne idea per slide.\nA second idea gets a second slide.\n\nEnd on one ask."}
```

Run locally (no `--url`, token or account):

```sh
flaghand slides convert --input input.json --format pdf --out ./carousel-export --json
flaghand slides convert --input input.json --format document --json
cat input.json | flaghand slides convert --input - --format zip --out ./carousel-pngs --json
```

`--out DIR` writes `slides.json` (the editable document) and the exported file. It refuses to overwrite an existing file. Without `--out`, stdout is the full JSON result, including base64 bytes. To re-render edited `slides.json`, wrap it as `{"document": <your slide document>, "format":"pdf"}` in a new input file.

For an offline-only MCP server, configure your client's stdio command as `flaghand mcp --local`. It lists `convertLocalSlides` with the same input schema and returns the same JSON result, beside the local post/thread image tools. It does not load the live API spec, read a workspace token or expose hosted workspace actions. Ordinary `flaghand mcp` also offers this explicitly local tool beside its hosted tools, but its normal hosted discovery may use the network. Use `convertLocalSlides`, not hosted `convertSlides`, to keep conversion local.

### Video (MP4)

The same input makes a video on this machine: each photo or colour slide shows for its `duration_ms` (else `--duration-ms`, else 3000), drawn by the bundled renderer and encoded as H.264 in a headless Chrome, Chromium, Edge or Brave (`--browser` or `FLAGHAND_BROWSER` picks one). Nothing is uploaded, saved or posted.

A document slide with `video` is a clip: name its file in `videos`, keyed by its `media_id`. It plays from `start_ms` to `end_ms` (default the file's end), cropped by `fit`, `zoom` and `focus` like a photo, with the slide's words over every frame. Its own sound stays unless `sound` is `false`; photo and colour slides are silent. AAC sound in one format is copied as it is, with silence between; other sound is encoded as AAC where the browser can, otherwise the export says which clip to turn off. A file the browser can't decode is refused by name.

```json
{ "document": { "slides": [
  { "video": { "media_id": "med_clip000000000001", "start_ms": 1000, "end_ms": 4000 }, "texts": [{ "text": "Day one" }] },
  { "background": "#ff3366", "duration_ms": 1500, "texts": [{ "text": "Follow for day two" }] }
] }, "videos": { "med_clip000000000001": "IMG_0142.MOV" } }
```

```sh
flaghand slideshows export-video --local --input input.json --out slideshow.mp4 --duration-ms 2500 --json
```

`--out` defaults to `slideshow.mp4` and never overwrites a file. `flaghand mcp --local` lists the same export as `exportLocalSlideshowVideo`; give it `out` to write a file, or it returns the MP4 as base64. There is no hosted video export yet.

## Hosted API and remote MCP

```sh
curl -fsS https://app.flaghand.com/api/v1/tools/convert-slides \
  -H 'Content-Type: application/json' \
  --data-binary @input.json > result.json
```

This public endpoint needs no bearer token. The generated API-backed CLI command is `flaghand tools convert-slides -d @input.json --json`; unlike `slides convert`, it sends content to the server. The hosted MCP operation is `convertSlides`, discovered with `getOperation` and called through `callReadOperation`; the remote MCP transport retains its normal sign-in requirement even though the HTTP conversion endpoint is public.

## Input and output

`convertSlides` takes exactly one of:

- `text`: the free carousel maker's Paste text → Make slides. A blank line starts a slide; without blank lines, each line does. The first slide is a forest-and-cream cover, followed by numbered slides. The same automatic type fitting applies.
- `document`: the [slideshow JSON](https://app.flaghand.com/docs/slideshows#the-document-version-1), including text, photo crops, colors and aspect.
- `photos`: an ordered array of JPEG, PNG or WebP files encoded as standard base64. Each becomes a 9:16 slide, like the TikTok maker. For another aspect or overlays, supply `document` and `images` instead.

- `split`: one wide photo split across slides that join edge to edge when swiped, as `{ "media_id": "med_panorama00000001", "across": 4 }` with the photo's bytes under that name in `images`. `across` defaults to as many slides as the photo fills at its full height, at least 2; `down` (default 1) makes rows; `aspect` defaults to `4:5`. Each slide crops whole, neighbouring pixels of the photo, so no pixel repeats or goes missing at a seam. The answer's `document` is ordinary slideshow JSON (each slide's `zoom` and `focus`): add text and convert it again. A profile grid of nine posts is `{ "media_id": …, "across": 3, "down": 3, "aspect": "3:4" }`; slides run left to right, then top to bottom, so post the last first.

For a document with photos, `images` maps each `image.media_id` to standard base64 bytes. These names are local to the request; no existing workspace media is read. URLs and data URLs are not supported. Every referenced photo must be supplied.

`format` is `document`, `png` (default), `zip` or `pdf`. `document` returns editable JSON without rendered files. `png` returns one PNG for one slide, otherwise a ZIP of ordered PNGs; `zip` always returns a ZIP. Optional `slide_index` selects one zero-based slide for PNG output. `pdf` returns the same lossless LinkedIn carousel PDF, with one page per slide. The inherited renderer rules still apply: up to 35 slides, 20 text items per slide and 2,000 characters per text. Pasted text uses the browser maker's existing truncation, and `cut` reports paragraphs/lines omitted past slide 35. Renderer warnings report missing glyphs or text outside the image.

The JSON answer contains `document`, `cut`, `width`, `height`, `warnings` and `files`. Each file has `name`, `mime_type`, `base64` and the SHA-256 of the decoded bytes. File names are `slide-01.png`, `slide-02.png`, and so on, or `carousel.pdf` / a ZIP. Decode the base64 to save a hosted result.
