# Extract thumbnail images from documents

Robot: `/document/thumbs`

🤖/document/thumbs generates an image for each page in a PDF file or an animated GIF file that loops through all pages.

## Things to keep in mind

* If you convert a multi-page PDF file into several images, all result images will be sorted with the first image being the thumbnail of the first document page, etc.
* You can also check the `meta.thumb_index` key of each result image to find out which page it corresponds to. Keep in mind that these thumb indices **start at 0,** not at 1.

Stage: ga

## Usage example

Convert all pages of a PDF document into separate 200px-wide images:

```json
{
  "steps": {
    "thumbnailed": {
      "resize_strategy": "fit",
      "robot": "/document/thumbs",
      "trim_whitespace": false,
      "use": ":original",
      "width": 200
    }
  }
}
```

## Parameters

<span aria-hidden="true" id="interpolate"></span>



### `interpolate`

Controls whether Assembly Variables are interpolated for individual instruction fields.

By default, most Robot instruction fields interpolate Assembly Variables. Set this to `false` to treat every instruction field as literal text, or set an individual field path to `false` to treat only that field as literal text. For Robot-specific fields that are literal by default, set this to `true` or set that field path to `true` to opt back into interpolation.

Use field names such as `path`, or dotted paths such as `ffmpeg.vf` for nested objects.

Type: `boolean | Record<string, boolean>`

<span aria-hidden="true" id="output_meta"></span>



### `output_meta`

Allows you to specify a set of metadata that is more expensive on CPU power to calculate, and thus is disabled by default to keep your Assemblies processing fast.

For images, you can add `"has_transparency": true` in this object to extract if the image contains transparent parts and `"dominant_colors": true` to extract an array of hexadecimal color codes from the image.

For images, you can also add `"blurhash": true` to extract a [BlurHash](https://blurha.sh) string — a compact representation of a placeholder for the image, useful for showing a blurred preview while the full image loads.

For images, `"thumbhash": true` instead extracts a base64-encoded [ThumbHash](https://evanw.github.io/thumbhash/) into `meta.thumbhash`, together with `meta.has_alpha` (whether an alpha channel exists, even when fully opaque). It describes EXIF-oriented pixels and uses the first frame of animated images. Extraction is best-effort: images above 40 megapixels, unsupported formats, or a failed/bounded decode produce no placeholder. Successful extraction adds a metadata charge equivalent to 20% of that file's bytes. No ThumbHash surcharge applies when disabled or when no hash is produced.

Set this option on the Step producing the image, such as `/upload/handle` for uploaded originals or `/image/resize` for processed outputs. Setting it only on `/transloadit/store` does not request extraction: storage preserves the producer's metadata. Transloadit Storage persists a generated hash with its immutable version and returns it in stored results and native asset reads. Direct S3 uploads do not generate placeholders. A placeholder contains image information, so protect it with the same access controls as the full image.

For videos, you can add the `"colorspace": true` parameter to extract the colorspace of the output video.

For videos, you can also add `"interlaced": true` to detect whether the video is interlaced. This combines the cheap ffprobe `field_order` flag with a bounded `idet` sampling pass over the first frames of the source, exposing `interlaced`, `field_order`, and a diagnostic `interlace_detection` object under `file.meta`. This is computationally expensive and billed accordingly.

For audio, you can add `"mean_volume": true` to get a single value representing the mean average volume of the audio file.

You can also set this to `false` to skip metadata extraction and speed up transcoding.

Type: `Record<string, boolean> | boolean | Array<string>`

<span aria-hidden="true" id="user_meta"></span>



### `user_meta`

Adds custom JSON metadata to each emitted file without changing its contents. Nested objects and arrays are supported.

Inheritance depends on the Robot. Values merge with existing `user_meta` on the output file; the current Step replaces matching top-level keys. Assign required keys explicitly when a Robot creates fresh outputs.

In processing Steps, `${file.*}` refers to the first input and `${result.*}` to the emitted file. Values are evaluated per output after the Robot runs, before subsequent metadata extraction and temporary storage. On `:original`, values are evaluated per upload before metadata extraction.

Downstream Steps read `${file.user_meta.key}`. See [Custom metadata](https://transloadit.com/docs/topics/assembly-variables.md#user-meta) for a complete example and inheritance rules.

Type: `Record<string, any>`

Default: `{}`

<span aria-hidden="true" id="result"></span>



### `result`

Whether the results of this Step should be present in the Assembly Status JSON

Type: `boolean`

Default: `false`

<span aria-hidden="true" id="queue"></span>



### `queue`

Setting the queue to 'batch', manually downgrades the priority of jobs for this step to avoid consuming Priority job slots for jobs that don't need zero queue waiting times

Type: `batch`

<span aria-hidden="true" id="force_accept"></span>



### `force_accept`

Force a Robot to accept a file type it would have ignored.

By default, Robots ignore files they are not familiar with.
[🤖/video/encode](/docs/robots/video-encode.md), for
example, will happily ignore input images.

With the `force_accept` parameter set to `true`, you can force Robots to accept all files thrown at them.
This will typically lead to errors and should only be used for debugging or combatting edge cases.

Type: `boolean`

Default: `false`

<span aria-hidden="true" id="ignore_errors"></span>



### `ignore_errors`

Ignore errors during specific phases of processing.

Setting this to `["meta"]` will cause the Robot to ignore errors during metadata extraction.

Setting this to `["execute"]` will cause the Robot to ignore errors during the main execution phase.

Setting this to `true` is equivalent to `["meta", "execute"]` and will ignore errors in both phases.

Type: `boolean | Array<meta | execute>`

Default: `[]`

<span aria-hidden="true" id="use"></span>



### `use`

Specifies which Step(s) to use as input.

* You can pick any names for Steps except `":original"` (reserved for user uploads handled by Transloadit)
* You can provide several Steps as input with arrays:
  ```json
  {
    "use": [
      ":original",
      "encoded",
      "resized"
    ]
  }
  ```
* You can also tag input Steps with `as` to pass semantic intent to robots:
  ```json
  {
    "use": [
      {
        "name": ":original",
        "as": "image"
      },
      {
        "name": ":original",
        "as": "mask"
      }
    ]
  }
  ```

> [!Tip]
> That's likely all you need to know about `use`, but you can view [Advanced use cases](/docs/topics/use-parameter.md).

Type: `string | Array<string> | Array<object> | object`

<span aria-hidden="true" id="imagemagick_stack"></span>



### `imagemagick_stack`

Type: `v3 | string`

Default: `"v2.0.10"`

<span aria-hidden="true" id="page"></span>



### `page`

The PDF page that you want to convert to an image. By default the value is `null` which means that all pages will be converted into images.

Type: `string | number | null`

Default: `null`

<span aria-hidden="true" id="page_range"></span>



### `page_range`

A page range to extract, in the format `"start-end"` (e.g., `"1-20"`). Extraction starts from the first page in the range and proceeds sequentially, stopping gracefully when a page does not exist. This is useful for PDFs where the total page count cannot be determined.

The start must be at least `1`, and the end must be greater than or equal to the start.

This parameter cannot be used together with `page`, and is not supported with GIF format. When `page_range` is set, the robot does not need to know the total page count upfront, making it robust for PDFs that fail page count detection.

Type: `string | null`

Default: `null`

<span aria-hidden="true" id="format"></span>



### `format`

The format of the extracted image(s).

If you specify the value `"gif"`, then an animated gif cycling through all pages is created. Please check out [this demo](/demos/document-processing/convert-all-pages-of-a-document-into-an-animated-gif.md) to learn more about this.

Type: `gif | jpeg | jpg | png`

Default: `"png"`

<span aria-hidden="true" id="delay"></span>



### `delay`

If your output format is `"gif"` then this parameter sets the number of 100th seconds to pass before the next frame is shown in the animation. Set this to `100` for example to allow 1 second to pass between the frames of the animated gif.

If your output format is not `"gif"`, then this parameter does not have any effect.

Type: `string | number`

<span aria-hidden="true" id="stack"></span>



### `stack`

Selects the PDF rendering stack. Defaults to Ghostscript.

Use `"pdfium"` for page-specific or single-page high-DPI PDF rasterization when Ghostscript is too slow or exhausts scratch space, for example with high-resolution CAD, blueprint, or layered real-estate PDFs. This stack uses PDFium via the Python `pypdfium2` bindings and Pillow for final image encoding.

Use `"vips"` only when you explicitly want libvips PDF loading. It is lower-overhead, but PDFium was faster in high-DPI floorplan tests while producing comparable output quality.

The `"pdfium"` stack currently supports JPG/PNG output, `resize_strategy: "fit"`, a specific `page` or single-page PDFs, opaque hexadecimal backgrounds, `antialiasing`, and `pdf_use_cropbox`.

The `"vips"` stack currently supports JPG/PNG output, `resize_strategy: "fit"`, a specific `page` or single-page PDFs, and hexadecimal or transparent backgrounds.

Type: `ghostscript | vips | pdfium`

<span aria-hidden="true" id="width"></span>



### `width`

Width of the new image, in pixels. If not specified, will default to the width of the input image

Type: `string | number`

<span aria-hidden="true" id="height"></span>



### `height`

Height of the new image, in pixels. If not specified, will default to the height of the input image

Type: `string | number`

<span aria-hidden="true" id="resize_strategy"></span>



### `resize_strategy`

One of the [available resize strategies](/docs/topics/resize-strategies.md).

Type: `crop | fillcrop | fit | min_fit | pad | stretch`

Default: `"pad"`

<span aria-hidden="true" id="background"></span>



### `background`

Either the hexadecimal code or [name](https://www.imagemagick.org/script/color.php#color_names) of the color used to fill the background (only used for the pad resize strategy).

By default, the background of transparent images is changed to white. For details about how to preserve transparency across all image types, see [this demo](/demos/image-processing/properly-preserve-transparency-across-all-image-types.md).

Type: `string`

Default: `"#FFFFFF"`

<span aria-hidden="true" id="alpha"></span>



### `alpha`

Change how the alpha channel of the resulting image should work. Valid values are `"Set"` to enable transparency and `"Remove"` to remove transparency.

For a list of all valid values please check the ImageMagick documentation [here](http://www.imagemagick.org/script/command-line-options.php#alpha).

Type: `Remove | Set`

<span aria-hidden="true" id="density"></span>



### `density`

While in-memory quality and file format depth specifies the color resolution, the density of an image is the spatial (space) resolution of the image. That is the density (in pixels per inch) of an image and defines how far apart (or how big) the individual pixels are. It defines the size of the image in real world terms when displayed on devices or printed.

You can set this value to a specific `width` or in the format `width`x`height`.

If your converted image has a low resolution, please try using the density parameter to resolve that.

Type: `string`

<span aria-hidden="true" id="antialiasing"></span>



### `antialiasing`

Controls whether or not antialiasing is used to remove jagged edges from text or images in a document.

Type: `boolean`

Default: `false`

<span aria-hidden="true" id="colorspace"></span>



### `colorspace`

Sets the image colorspace. For details about the available values, see the [ImageMagick documentation](https://www.imagemagick.org/script/command-line-options.php#colorspace).

Please note that if you were using `"RGB"`, we recommend using `"sRGB"`. ImageMagick might try to find the most efficient `colorspace` based on the color of an image, and default to e.g. `"Gray"`. To force colors, you might then have to use this parameter.

Type: `CMY | CMYK | Gray | HCL | HCLp | HSB | HSI | HSL | HSV | HWB | Jzazbz | Lab | LCHab | LCHuv | LMS | Log | Luv | OHTA | OkLab | OkLCH | Rec601YCbCr | Rec709YCbCr | RGB | scRGB | sRGB | Transparent | Undefined | xyY | XYZ | YCbCr | YCC | YDbDr | YIQ | YPbPr | YUV`

<span aria-hidden="true" id="trim_whitespace"></span>



### `trim_whitespace`

This determines if additional whitespace around the PDF should first be trimmed away before it is converted to an image. If you set this to `true` only the real PDF page contents will be shown in the image.

If you need to reflect the PDF's dimensions in your image, it is generally a good idea to set this to `false`.

Type: `boolean`

Default: `true`

<span aria-hidden="true" id="pdf_use_cropbox"></span>



### `pdf_use_cropbox`

Some PDF documents lie about their dimensions. For instance they'll say they are landscape, but when opened in decent Desktop readers, it's really in portrait mode. This can happen if the document has a cropbox defined. When this option is enabled (by default), the cropbox is leading in determining the dimensions of the resulting thumbnails.

Type: `boolean`

Default: `true`

<span aria-hidden="true" id="turbo"></span>



### `turbo`

Enables high-performance mode for faster document processing.

When enabled, Turbo Mode provides two key optimizations:

1. **Parallel page extraction**: For documents with more than 5 pages, multiple processes run in parallel to extract pages simultaneously. The number of parallel processes scales with the document size (up to 4 processes for documents with 13+ pages).

2. **Distributed resizing**: Extracted pages are resized concurrently on multiple machines, providing up to 20 times faster processing for large documents.

Files are emitted as they become available during processing. If you set this to `false`, pages are extracted sequentially using a single process, and files are emitted only after all processing is complete.

Turbo Mode increases pricing in that the input document's file size is added for every extracted page. There are no performance benefits nor increased charges for single-page documents.

Type: `boolean`

Default: `true`
