Skip to main content

thumbrella-client

Python client for Thumbrella, a fast thumbnail server for images, video, documents, and more.

PyPI version Python License

The client git repository also has packages for other languages and environments. See Typescript, Rust, and more coming soon.

Features

  • Client defaults to synchronous requests with requests
  • Async support via thumbrella-client[async] using aiohttp
  • Single call efficiently processes multiple thumbnails in parallel
  • Persistent client caching integrates with server and HTTP
  • Placeholders for failures, even if disconnected or misconfigured
  • Typed results with simple media metadata
  • Load easily into PIL, Qt, Pygame, and others
  • Thumbrella server supports 100+ formats

Quickstart

Install with your package manager of choice using thumbrella-client or thumbrella-client[async].

uv add thumbrella-client
pip install thumbrella-client
import thumbrella

# Client() reads $TBR_CONNECT from the environment.
# verify() checks the server is reachable and auth is valid.
tbr = thumbrella.Client().verify()

# Single URL — returns a Result with the thumbnail JPEG.
result = tbr.thumb("https://www.pygame.org/docs/_images/pygame_lofi.png")
if result.is_success():
    print(len(result.media.thumbnail), "bytes")

# Batch many URLs at once.
results = tbr.batch([
    "https://www.python.org/static/img/python-logo-large.png",
    "https://web.mit.edu/18.417/doc/pydocs/ref.pdf",
])
for r in results:
    print(r.url, r.status, r.media.kind)

# Stream results as the server completes each thumbnail (requires aiohttp).
import asyncio

async def stream_example():
    tbr = thumbrella.Client()
    async for r in tbr.stream([
        "https://www.python.org/static/img/python-logo-large.png",
        "https://web.mit.edu/18.417/doc/pydocs/ref.pdf",
    ]):
        print(r.url, r.status)

asyncio.run(stream_example())

# Requests can carry an explicit cache key. Plain strings still work.
result = tbr.thumb({"url": "https://example.com/a.png?sig=1", "key": "avatar/1"})

How It Works

Create a Client with server configuration and optional caches. Call verify() to confirm connectivity. Then use thumb(), batch(), or stream() to generate thumbnails.

Every URL gets a Result — even failures produce a result with a placeholder image and an error message. Use result.verify() to raise an exception on failure, or check result.is_success() for inline handling.

Connect Strings

The client reads $TBR_CONNECT by default. Pass a connect string to override:

# Local dev server (no auth)
thumbrella.Client("http://localhost:3114")

# Cloud service with auth token
thumbrella.Client("tbr_e_3QnzBcWx7KpRmYT2000example")

The connect string can also define custom headers. Thumbrella servers can define an additional handshake token to prevent unwanted users. The documentation describes these in more detail at, https://thumbrella.dev/docs/client/#connect

The Client object defines a requests.Session attribute which can be further customized for proxies, TLS certificates, cookies, or other HTTP-level configuration.

Result

result.key         # str — effective cache identity (request key or canonical URL)
result.url         # str — the requested URL
result.status      # "success" | "failed" | "overloaded" | "intermediate" | ...
result.source      # "render" | "cache" | "fallback" | "placeholder" | ...
result.media       # Media | None — None when thumbnail could not be generated
result.duration    # float — server processing time (ms)
result.message     # str — error or informational message
result.pin         # str | None — reusable url to fetch thumbnail contents

result.is_success()  # True for SUCCESS or INTERMEDIATE
result.is_fresh()    # True when the server freshly rendered (not from cache)
result.verify()      # returns self on success, raises ThumbError on failure

All the result properties are documented at, https://thumbrella.dev/docs/client/#result

Media

media.url          # str — simplified URL; use result.key for identity
media.mime         # "image/jpeg" | "application/pdf" | ...
media.kind         # "image" | "video" | "document" | "vector" | "geometry" | ...
media.file_size    # int — original file size in bytes
media.thumbnail    # EncodedJpeg — the thumbnail JPEG bytes

All the result properties are documented at, https://thumbrella.dev/docs/client/#media

EncodedJpeg

jpeg.bytes         # bytes — decoded JPEG bytes (lazy, cached)
jpeg.io            # _BytesIO — file-like object, compatible with PIL and numpy
len(jpeg)          # int — byte count
jpeg.key           # str — content hash, useful for deduplication

PIL integration:

from PIL import Image
img = Image.open(result.media.thumbnail.io)

The source comes with several starting point examples. See the client documentation for more details and examples.

Servers

This client works with any self-hosted Thumbrella server and also the online Thumbrella Cloud service. Both are configured using the $TBR_CONNECT environment variable. Alternatively, a connect string can be passed to the Client constructor.

Thumbrella provides a demo gallery and server that can be used for free with no account and no signup.

License

Apache-2.0. See LICENSE.

Metadata

Release files for thumbrella-client 2.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thumbrella-client 2.3.1
File Size Uploaded Provenance Actions
thumbrella_client-2.3.1.tar.gz 34.3 kB With provenance Details for thumbrella_client-2.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thumbrella-client 2.3.1
File Interpreter ABI Platform Actions
thumbrella_client-2.3.1-py3-none-any.whl Python 3 none any Details for thumbrella_client-2.3.1-py3-none-any.whl

Total release size: 61.0 kB

Release files / thumbrella_client-2.3.1.tar.gz

Download URL thumbrella_client-2.3.1.tar.gz
Size 34.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fffed4c5e8c428a6e83bd6e50e3d782175f71918dd3b5088a70a6c34777ff9b4
BLAKE2b-256 checksum
How to use checksums
b77a7e31381093d61516e7dcbe746c04115dcdf6e799b9824f80344f676f291b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / thumbrella_client-2.3.1-py3-none-any.whl

Download URL thumbrella_client-2.3.1-py3-none-any.whl
Size 26.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8050233cffd112eb478e2a844073eeb98685a03f472563ea394b863a6ea3ea2d
BLAKE2b-256 checksum
How to use checksums
7da6615c4fcdb88b0213f621a593a0326f5afc1999aaac59940b6bc1e671bf49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for thumbrella-client 2.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for thumbrella_client-2.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page