Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

The powerful, yet easy to implement thumbnailing application for Django.

To install this application into your project, just add it to your INSTALLED_APPS setting (and run manage.py syncdb):

INSTALLED_APPS = (
    ...
    'easy_thumbnails',
)

Template usage

To generate thumbnails in your template, use the {% thumbnail %} tag. To make this tag available for use in your template, use:

{% load thumbnail %}

Basic tag Syntax:

{% thumbnail [source] [size] [options] %}

source must be a File object, usually an Image/FileField of a model instance.

size can either be:

  • the size in the format [width]x[height] (for example, {% thumbnail person.photo 100x50 %}) or

  • a variable containing a valid size (i.e. either a string in the [width]x[height] format or a tuple containing two integers): {% thumbnail person.photo size_var %}.

options are a space separated list of options which are used when processing the image to a thumbnail such as sharpen, crop and quality=90.

Model usage

You can use the ThumbnailerField or ThumbnailerImageField fields (based on FileField and ImageField, respectively) for easier access to retrieve (or generate) thumbnail images.

By passing a resize_source argument to the ThumbnailerImageField, you can resize the source image before it is saved:

class Profile(models.Model):
    user = models.ForeignKey('auth.User')
    avatar = ThumbnailerImageField(
        upload_to='avatars',
        resize_source=dict(size=(50, 50), crop='smart'),
    )

Lower level usage

Thumbnails are generated with a Thumbnailer instance. For example:

from easy_thumbnails import Thumbnailer

def square_thumbnail(source):
    thumbnail_options = dict(size=(100, 100), crop=True, bw=True)
    return Thumbnailer(source).get_thumbnail(thumbnail_options)

By default, get_thumbnail saves the file (using file storage). The source file used to instanciate the Thumbnailer must have a name instance relative to the storage root.

The ThumbnailFile object provided makes this easy:

from easy_thumbnails import ThumbnailFile

# For an existing file in storage:
source = ThumbnailFile('animals/aarvark.jpg')
square_thumbnail(source)

# For a new file:
picture = open('/home/zookeeper/pictures/my_anteater.jpg')
source = ThumbnailFile('animals/anteater.jpg', file=picture)
square_thumbnail(source)

Metadata

Release files for easy-thumbnails 1.0-alpha-4

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

Source distribution (sdist)

Source distribution for easy-thumbnails 1.0-alpha-4
File Size Uploaded
easy-thumbnails-1.0-alpha-4.tar.gz 25.2 kB Details

Release files / easy-thumbnails-1.0-alpha-4.tar.gz

Download URL easy-thumbnails-1.0-alpha-4.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
92611954270d71cb17d83e7fcd1f2b160bce7a6b406fe0071a83aea331fd1228
BLAKE2b-256 checksum
How to use checksums
8ed15f62b74fedc3a4a0345d048ce03056be393e7ce5e1b6c211f477cab0f86f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.10.1

2 release files

2.10

2 release files

2.9

2 release files

2.8.5

2 release files

2.8.4

2 release files

2.8.3

2 release files

2.8.2

2 release files

2.8.1

2 release files

2.8

2 release files

2.7.2

2 release files

2.7.1

1 release file

2.7

1 release file

2.6

1 release file

2.5

1 release file

2.4.2

1 release file

2.4.1

2 release files

2.3

2 release files

2.2.1

2 release files

2.2

1 release file

2.1

1 release file

2.0.1

1 release file

2.0

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0

1 release file

This release

1.0-alpha-4 This release

1 release file

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