Skip to main content

Thumbnails for Django

Project description

travis pypi coveralls

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.

Support

If you need help using sorl-thumbnail browse http://stackoverflow.com/questions/tagged/sorl-thumbnail or 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sorl-thumbnail-12.1c.tar.gz (521.1 kB view details)

Uploaded Source

Built Distributions

sorl_thumbnail-12.1c-py2.py3-none-any.whl (38.5 kB view details)

Uploaded Python 2 Python 3

sorl_thumbnail-12.1c-py2.7.egg (84.1 kB view details)

Uploaded Source

File details

Details for the file sorl-thumbnail-12.1c.tar.gz.

File metadata

File hashes

Hashes for sorl-thumbnail-12.1c.tar.gz
Algorithm Hash digest
SHA256 5565cfad7d98d690bef6a39db1a52e5199a8557bc40f3da435e55876d385a2cb
MD5 c468f0ab9ff0d862451b70998167bb45
BLAKE2b-256 053aff636cead1fdd2f4b9670662c1fb2dfeb414dbc7a5d8019d8cfe2d0f5017

See more details on using hashes here.

File details

Details for the file sorl_thumbnail-12.1c-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sorl_thumbnail-12.1c-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4f3d719545e610a156e1cae12c5ce7e9ef02ad5bdc57521f43a52dc4128e9a96
MD5 5a620a0873b2f9670f536476350da17a
BLAKE2b-256 c673cbe91a29e938c4c1843e4fdd2d23cc882c1240eaff03f2d5a0264d67d632

See more details on using hashes here.

File details

Details for the file sorl_thumbnail-12.1c-py2.7.egg.

File metadata

File hashes

Hashes for sorl_thumbnail-12.1c-py2.7.egg
Algorithm Hash digest
SHA256 37e16972199deb5aca8e91348b41148f285d565836f9ae2aa3e066bd7549e8a8
MD5 b5b9bc25dbad95749369aad7997645d0
BLAKE2b-256 87f7469b6afcf6fb576d227ecb7d9deaeb6ff7dd9c0d02ea20f464e2da483145

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page