django-thumborize
Minimal interface for thumbor imaging service.
Features
Easy thumbor URLs
Easily build thumbor URLs with arguments and filters by calling simple functions.
Default filters
Set default filters to be used on thumborized URLs. These filters can be overridden by any calls that specify the same filters with different parameters.
Flexible filters specification
Filters can be either a string delimited by :, a list or dict. See usage for more.
Chaining
Easy, queryset like chaining for applying filters and resizing.
For a full list of available filters, check thumbor’s wiki.
Usage
from thumborize import ThumborURL
# Filters as string.
thumbor_url = ThumborURL("http://path/to/image.png", width=320,
filters="quality(80):grayscale()")
# Filters as list.
thumbor_url = ThumborURL("http://path/to/image.png", width=320,
filters=["quality(80)", "grayscale()"])
# Filters as dict.
thumbor_url = ThumborURL("http://path/to/image.png", width=320,
filters={
"quality": "(80)",
"grayscale": "()",
})
thumbor_url.generate()
'http://localhost:8888/JiuVg9d5Mry_kw4odvb5Zh1C_BY=/320x0/filters:quality(80):grayscale()/http://path/to/image.png'
Chaining
from thumborize import ThumborURL
thumbor_url = ThumborURL("http://path/to/image.png")
small_gray_image = thumbor_url.grayscale().resize(width=100, height=100)
small_gray_image.generate()
'http://localhost:8888/RFsfJakG9BsJUcbY2l1M6D5tthQ=/100x100/filters:grayscale()/http://path/to/image.png'
low_quality_image = thumbor_url.quality(40).width(200)
'http://localhost:8888/SB1ILIArmGzsd90-Mz-TxJVHwqI=/200x0/filters:quality(40)/http://path/to/image.png'
# Original ThumborURL instance.
thumbor_url.generate()
'http://localhost:8888/O0Zqo6DMqqXHORdYncuspoaJlr0=/http://path/to/image.png'
Shortcut
import thumborize
thumborize.url("http://path/to/image.png", width=320, height=300)
'http://localhost:8888/DYStA-Xwisc37dVz7bdXZ3u63QI=/320x300/http://path/to/image.png'
Templates
{% load thumborize %}
<!-- Filters as string -->
<img src="{% thumborize some_url width=320 filters='quality(80):grayscale()' %}"/>
<!-- Filters as a list object -->
<img src="{% thumborize some_url width=320 filters=filter_list %}"/>
Installation
Install using pip:
$ pip install django-thumborize
In order to use django-thumborize templatetags, you must add the app to INSTALLED_APPS:
INSTALLED_APPS = (
# Other django apps..
"thumborize", # Any order is fine.
)
Configure basic thumbor settings:
# Thumbor host URL.
THUMBOR_SERVER = "http://localhost:8888/"
# This key must be the same used in thumbor
# host to build safe URLs correctly.
THUMBOR_SECURITY_KEY = "MY_SECURE_KEY"
# Default filters are optional.
THUMBOR_DEFAULT_FILTERS = {
"quality": "(80)",
"grayscale": "()",
}
Testing
Install
First clone the repository, then run make install to install dev requirements.
Run tests
Run make test to run tests.
Metadata
Release files for django-thumborize 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-thumborize-1.0.tar.gz | 4.6 kB | Without provenance | Details for django-thumborize-1.0.tar.gz |
Release files / django-thumborize-1.0.tar.gz
| Download URL | django-thumborize-1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61ca155fa7adc99a4411867081bd7fbf3240cac90ae26d6827c105e30e56fcfc
|
|
BLAKE2b-256 checksum How to use checksums |
a092c352fc793d5748dd08764d1e627fddd541b68f418a1ca40a925d6027e2fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-thumborize 1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.