Skip to Content

Image rendering

Turn document pages, images and web pages into previews and page images

POST /v1/thumbnail and POST /v1/render turn any page of a document or image into a picture: thumbnails are fixed size previews for your UI, renders are pages at reading size, for viewers and vision models. Both return the image file by default.

curl http://127.0.0.1:8000/v1/thumbnail \
  -H 'Authorization: Bearer dev' \
  -F file=@sample.pdf \
  -o sample.webp

The result is a WebP of at most 256 × 256 px, here 198 × 256 for a portrait page.

Pick the endpoint

You needUseDefault output
The same box for every file, in a list or gridthumbnailWebP inside 256 × 256
A link preview for a websitethumbnail with a URLWebP of the page top, as on a desktop screen
A page to read, zoom or send to a vision modelrenderPNG at 150 dpi
A page at an exact width for a layoutrender with widthPNG

Thumbnails

Set the box with width and height (default 256, up to 4096) and choose how the page fills it:

fitResult
contain (default)The whole page fits in the box; one side can come out shorter
coverThe page fills the box and the center is cropped; the output is exactly the box
curl http://127.0.0.1:8000/v1/thumbnail \
  -H 'Authorization: Bearer dev' \
  -H 'Content-Type: application/json' \
  -d '{"source": "https://axelered.com/_og/platform.png", "options": {"width": 320, "height": 200, "fit": "cover"}}' \
  -o card.webp

Website previews

A URL that serves HTML is captured in a headless browser instead of being paginated: Papyrus loads the page at 1280 px wide, with a viewport height that matches your box shape (between 400 and 2160 px), and scales the capture into the box. A 400 × 300 box captures a 1280 × 960 viewport.

curl http://127.0.0.1:8000/v1/thumbnail \
  -H 'Authorization: Bearer dev' \
  -H 'Content-Type: application/json' \
  -d '{"source": "https://axelered.com", "options": {"width": 400, "height": 300}}' \
  -o axelered.webp

An uploaded HTML file is captured the same way, but without the images and stylesheets it references by relative path, since there is no site to load them from.

Renders

Size the page one way only:

OptionsResult
noneDocument pages at 150 dpi, images at their own size
dpi1 to 600; images ignore it
width or height1 to 4096; the other side follows the aspect ratio
width and heightThe page fits inside the box
curl http://127.0.0.1:8000/v1/render \
  -H 'Authorization: Bearer dev' \
  -F 'metadata={"options": {"page": 1, "width": 800, "format": "webp"}};type=application/json' \
  -F file=@sample.pdf \
  -o sample-1.webp

The file is named <source name>-<page>.<ext>. With output: json, source.pageCount tells you how many pages to request for a PDF or image.

Formats and limits

  • Inputs: PDF, PNG, JPEG, WebP, GIF, BMP, TIFF, AVIF, Word, PowerPoint, Excel, OpenDocument, RTF and HTML. page picks the frame of a GIF, TIFF or animated WebP.
  • Outputs: format is png, jpeg or webp.
  • Each request renders one page. Send several requests in parallel to render more, and the server processes them concurrently.
  • Office files are exported one page at a time through LibreOffice, so they are slower than PDFs and report no pageCount. If you render many pages of one office document, export it to PDF once in your own pipeline and render the PDF.
  • Images are not scaled above their own size, and no output side exceeds 4096 px.
  • Images with more pixels than the decompression guard allows fail with 413 image_too_large.
  • page past the end fails with 422 page_out_of_range, and dpi combined with width or height with 422 validation_error.

On this page