Skip to main content

opposable-thumbs

Make thumbnails and simple image edits from Python, or serve them from your web app with URLs like /thumb?file=media/photo.jpg&p=fit,300,300&format=webp.

It is designed to plug into a project you already have: install it, add a few lines, and your app serves its own thumbnails, with no separate image server, reverse proxy or other infrastructure to run. Sources must be allowed explicitly, URLs are signed, and every request is limited in size and work, so it is safe to expose to the public.

It isn't trying to compete with dedicated image servers such as Thumbor or imgproxy. They are faster and do more, e.g. face-aware cropping, cloud storage and animated images. If you serve a lot of images, or speed matters most, use one of those instead.

Requires Python 3.11+. Uses Pillow for images and requests to fetch remote ones.

Install

pip install opposable-thumbs

For the Django or Flask integration, install opposable-thumbs[django] or opposable-thumbs[flask] instead, which also requires the framework.

Quick start

Django

# settings.py
INSTALLED_APPS = [..., "opposable_thumbs.django"]
OPPOSABLE_THUMBS = {"roots": {"media": MEDIA_ROOT}}

# urls.py
urlpatterns = [..., path("thumb/", include("opposable_thumbs.django.urls"))]
{% load opposable_thumbs %}
<img src="{% thumbnail_url "media/photo.jpg" "fit,300,300|unsharp" format="webp" %}">

More in Using with Django.

Flask

from opposable_thumbs.flask import init_app

app.config["OPPOSABLE_THUMBS"] = {"roots": {"media": "/srv/media"}}
init_app(app)
<img src="{{ thumbnail_url('media/photo.jpg', operations='fit,300,300|unsharp') }}">

More in Using with Flask.

Python

from opposable_thumbs import Config, make_thumbnail

config = Config(roots={"media": "/srv/media"})
thumbnail = make_thumbnail(
    config, file="media/photo.jpg", operations="fit,300,300", format="webp"
)
thumbnail.data  # the image, as bytes

More in The Python API, and for other web frameworks, see Using with another web framework.

Features

  • 29 operations, including fit, pad, cropratio, rotate, circle, rounded, unsharp and colour adjustments, with JPEG, PNG, WebP, GIF, BMP and TIFF output.
  • Signed URLs, so nobody can make up their own.
  • Sources from named folders or allowed URLs only, with limits on download size, image size and work per request.
  • Optional caches for downloaded sources and finished thumbnails, plus ETag, Cache-Control and 304 Not Modified for browsers and CDNs.
  • Faster, lower-memory decoding of large JPEGs, and EXIF orientation applied so phone photos come out upright.

Documentation

The repository also has a playground for trying every operation in a browser, and a guide to working on the project: see DEVELOP.md.

Licence

BSD 3-Clause. See LICENCE.

Metadata

Release files for opposable-thumbs 0.2.0

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

Source distribution (sdist)

Source distribution for opposable-thumbs 0.2.0
File Size Uploaded Provenance
opposable_thumbs-0.2.0.tar.gz 59.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for opposable-thumbs 0.2.0
File Interpreter ABI Platform
opposable_thumbs-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 91.8 kB

Release files / opposable_thumbs-0.2.0.tar.gz

Download URL opposable_thumbs-0.2.0.tar.gz
Size 59.3 kB
Tags Source
SHA-256 checksum
How to use checksums
527b98cb91dc7ca7b4e510b2ceaafa28d22480c3af9ce5806d0cafc75b19f7ca
BLAKE2b-256 checksum
How to use checksums
8f6ce9667f5996a0f47e1867b5ead1f41baf0f3f1f71f3c981d23f0c390d4a3e
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 Oct 25, 2026.

Transparency log

Release files / opposable_thumbs-0.2.0-py3-none-any.whl

Download URL opposable_thumbs-0.2.0-py3-none-any.whl
Size 32.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
432bb11b5bb5f8891a366df3fb5e6ca7ebff3fbcde9c945b33a8df5e972bf05c
BLAKE2b-256 checksum
How to use checksums
a64879914d6def5f915e702770e1e0ac8eb71c26e56374f55282a929059a33b2
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 Oct 25, 2026.

Transparency log

Security for opposable-thumbs 0.2.0

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opposable_thumbs-0.2.0.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 Oct 25, 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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