Skip to content
Easy powerful thumbnails for Django: http://code.google.com/p/django-thumbs mirror ('original' branch) and fork ('master' branch).
Python
Find file
Pull request Compare This branch is 3 commits ahead, 13 commits behind djromero:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
thumbsfield
.gitignore
LICENSE
README.rst
setup.py

README.rst

Django-thumbs

The easiest way to create thumbnails for your images with Django. Works with any StorageBackend.

Features

  • Easy to integrate in your code (no database changes, works as an ImageField)
  • Works perfectly with any StorageBackend
  • Generates thumbnails after image is uploaded into memory
  • Deletes thumbnails when the image file is deleted
  • Provides easy access to the thumbnails' URLs (similar method as with ImageField)

Requirements

  • Python 2.5+
  • Django 1.1+
  • PIL (Python Image Library)

Working example

from django.db import models
from thumbsfield import ImageWithThumbsField

class Person(models.Model):
    photo = ImageWithThumbsField(upload_to='images', sizes=((125,125),(200,200)))
    second_photo = ImageWithThumbsField(upload_to='images')

In this example we have a Person model with 2 image fields.

You can see the field second_photo doesn't have a sizes attribute. This field works exactly the same way as a normal ImageField.

The field photo has a sizes attribute specifying desired sizes for the thumbnails. This field works the same way as ImageField but it also creates the desired thumbnails when uploading a new file and deletes the thumbnails when deleting the file.

With ImageField you retrieve the URL for the image with: someone.photo.url With ImageWithThumbsField you retrieve it the same way. You also retrieve the URL for every thumbnail specifying its size: In this example we use someone.photo.url_125x125 and someone.photo.url_200x200 to get the URL of both thumbnails.

Something went wrong with that request. Please try again.