# fs.image.thumbnail

Make a small image from the one --from names — a FileRef, an upload or a store key

# fs.image.thumbnail

```
fs.image.thumbnail --from IMAGE [--width N] [--height N] [--fit cover|contain|fill] [--format jpg|png|webp] [--quality N] [--delete-source] [--store TEXT] [--folder TEXT] [--filename TEXT] [--path TEXT] [--on-conflict error|skip|overwrite] → image
```

Make a small image from the one `--from` names — a FileRef, an upload or a store key. Resizes to `--width`×`--height` (default 256) with `--fit cover|contain|fill` and re-encodes as `--format jpg|png|webp` (`--quality` for jpg), so the result is sanitized whatever came in. Writes under `--folder` (default `thumbnails`) as a generated name, as `--filename`, or at an exact `--path`; a named file that exists is an error unless `--on-conflict` says otherwise. `--delete-source` removes the original once the thumbnail is written. Adds `image` — the durable FileRef (`ref`, `store`, …, `origin: fs.image.thumbnail`, `trust: sanitized`) with `width`, `height`, `format` and `source_deleted` — and keeps the rest of the payload. Store `image.ref` in the row.

## Flags

- `--from` (required): The image: a FileRef, an upload or a store key.
- `--width`: Target width in pixels (default: 256).
- `--height`: Target height in pixels (default: 256).
- `--fit`: cover (default: fill the box, crop the middle), contain or fill.
- `--format`: jpg (default), png or webp.
- `--quality`: JPEG quality 1–100 (default: 82).
- `--delete-source`: Delete the source once the thumbnail is written.
- `--store`: The project store to write to: `local`, or the id of an `s3` credential. Saved explicitly when the pipeline is registered (default: the project's default store at that moment)
- `--folder`: Destination folder (default: thumbnails).
- `--filename`: Destination name without extension (default: a generated name).
- `--path`: Exact destination key; overrides --folder and --filename.
- `--on-conflict`: When the target already exists: overwrite, skip or error (default: error)

## Examples

### Avatar after an upload

```
| fs.image.thumbnail --from "{{ input.file }}" --width 320 --height 320 --fit cover --format webp --folder thumbs
```

After `fs.file.put --from "{{ input.webhook.files.photo }}"`; store `input.image.ref` in the row.

Input:

```json
{
  "webhook": {
    "body": {
      "caption": "Sunset"
    }
  },
  "file": {
    "__zf_type": "file_ref",
    "backend": "zebfs",
    "store": "local",
    "ref": "uploads/3f9c….jpg",
    "filename": "3f9c….jpg",
    "mime": "image/jpeg",
    "kind": "image",
    "size": 182331,
    "sha256": "sha256:…",
    "lifecycle": "durable",
    "origin": "fs.file.put",
    "trust": "untrusted"
  }
}
```

It answers:

```json
{
  "webhook": {
    "body": {
      "caption": "Sunset"
    }
  },
  "file": {
    "__zf_type": "file_ref",
    "backend": "zebfs",
    "store": "local",
    "ref": "uploads/3f9c….jpg",
    "filename": "3f9c….jpg",
    "mime": "image/jpeg",
    "kind": "image",
    "size": 182331,
    "sha256": "sha256:…",
    "lifecycle": "durable",
    "origin": "fs.file.put",
    "trust": "untrusted"
  },
  "image": {
    "__zf_type": "file_ref",
    "backend": "zebfs",
    "store": "local",
    "ref": "thumbs/9a1d….webp",
    "filename": "9a1d….webp",
    "mime": "image/webp",
    "kind": "image",
    "size": 8120,
    "sha256": "sha256:…",
    "lifecycle": "durable",
    "origin": "fs.image.thumbnail",
    "trust": "sanitized",
    "width": 320,
    "height": 320,
    "format": "webp",
    "source_deleted": false
  }
}
```
