Thumbnails for Django
Project description
Thumbnails for Django.
Features at a glance
Support for Django 1.4, 1.5, 1.6 and 1.7
Python 3 support (for Django 1.5, 1.6, 1.7)
Storage support
Pluggable Engine support for Pillow, ImageMagick, PIL, Wand and pgmagick
Pluggable Key Value Store support (cached db, redis)
Pluggable Backend support
Admin integration with possibility to delete
Dummy generation (placeholders)
Flexible, simple syntax, generates no html
ImageField for model that deletes thumbnails
CSS style cropping options
Back smart cropping, and remove borders from the images when cropping
Margin calculation for vertical positioning
Alternative resolutions versions of a thumbnail
Read more in the documentation (latest version)
Developers
Feel free to create a new Pull request if you want to propose a new feature. If you need development support or want to discuss with other developers join us in the channel #sorl-thumnbnail at freenode.net or Gitter.
For releases updates and more in deep development discussion use our mailing list in Google Groups.
User Support
If you need help using sorl-thumbnail browse http://stackoverflow.com/questions/tagged/sorl-thumbnail and posts your questions with the sorl-thumbnail tag.
How to Use
Get the code
Getting the code for the latest stable release use ‘pip’.
$ pip install sorl-thumbnail
Install in your project
Then register ‘sorl.thumbnail’, in the ‘INSTALLED_APPS’ section of your project’s settings.
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.admin', 'django.contrib.sites', 'django.contrib.comments', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.contenttypes', 'sorl.thumbnail', )
Templates Usage
All of the examples assume that you first load the thumbnail template tag in your template.:
{% load thumbnail %}
A simple usage.
{% thumbnail item.image "100x100" crop="center" as im %} <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"> {% endthumbnail %}
See more examples in the section Template examples in the Documentation
Model Usage
Using the ImageField that automatically deletes references to itself in the key value store and its thumbnail references and the thumbnail files when deleted.:
from django.db import models from sorl.thumbnail import ImageField class Item(models.Model): image = ImageField(upload_to='whatever')
See more examples in the section Model examples in the Documentation
Low level API
You can use the ‘get_thumbnail’:
from sorl.thumbnail import get_thumbnail from sorl.thumbnail import delete im = get_thumbnail(my_file, '100x100', crop='center', quality=99) delete(my_file)
See more examples in the section Low level API examples in the Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file sorl-thumbnail-12.2.tar.gz
.
File metadata
- Download URL: sorl-thumbnail-12.2.tar.gz
- Upload date:
- Size: 523.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e829636f838c5146b66f7426ced5219a48463260162b566a207330778a533226 |
|
MD5 | 1b32219a21640cba71b6ebe10b83fb41 |
|
BLAKE2b-256 | 99f5e628bb39b951b642b306042e5533d2070d8e07ce9b569d3391ab1b56d074 |
File details
Details for the file sorl_thumbnail-12.2-py2.py3-none-any.whl
.
File metadata
- Download URL: sorl_thumbnail-12.2-py2.py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12b23975ddb6baca8beb8072a2d605106018dbdaa09ebba4ba20facf512f46c6 |
|
MD5 | 33e9235ae87d29d0fc952f184de0e963 |
|
BLAKE2b-256 | fcb69dec2841a0fc8ad2471058a24ceeb6799521c74ae160832e107789c63513 |
File details
Details for the file sorl_thumbnail-12.2-py2.7.egg
.
File metadata
- Download URL: sorl_thumbnail-12.2-py2.7.egg
- Upload date:
- Size: 86.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47c64d27bd3822f19536ac53687814362cfdcb82fd62f9cdf4d1207451690d80 |
|
MD5 | 59d2e7680604e06bf44480f5ce4eede7 |
|
BLAKE2b-256 | d70dd91c38f91e9830780dcd725d76e5708d20c27ca11daa4006a8660147df82 |