This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Version : 0.1.0 Author : Thomas Weholt <> License : GPL v3.0 WWW : Status : Experimental


  • Templatetags for thumbnail generation, supports automatic rotation based on EXIF.Orientation.
  • Planned routines for metadata handling (EXIF/IPTC/XMP).


<img src=”{% generate_thumbnail imagefile 100x100 crop %}”/>

Provides a templatetag called generate_thumbnail which takes two or three parameters:

Param #1 : an object (imagefile), like a model instance, with a property/field called unique_filename, complete_filename or filename. Photofile will check in that order.

Param #2: resolution, specified as <width>x<height>, like 320x280.

Param #3: optional “crop” - which will enforce cropping of the photo.

The thumbnail will be written in a dir called “thumbs” in your STATICFILES_DIRS or STATIC_ROOT. If no dir exists called thumbs, it will be created.

The generated thumbnail will be named <filename>_<width>x<height>.<extension>. When cropping is used it will be named <filename>_<width>x<height>_crop.<extension>. For instance, thumbnail for test.jpg in resolution 200x300 will be named test_200x300.jpg.

Photofile will try to use caching if enabled, but it caches the url to the thumbnail, not the image itself so it’s not very efficient yet.

NB! It’s highly recommended to have some way of ensuring that the filename given to photofile is unique. That’s why it will look for a property called unique_filename first.

Why another thumbnail app for django?

I’ve looked at sorl-thumbnail and others, and initially I wanted to use an existing project, but none of them supported automatic rotation based on EXIF.Orientation.


Alternative a) pip install django-photofile. Alternative b) download source, unpack and do python install. Alternative c) hg clone and do python install.


In 1. Add ‘photofile’ to your INSTALLED_APPS. 2. Set up caching if you want. 3. Add a dir to your STATICFILES_DIRS or set STATIC_ROOT.

In your template: {% load photofile_tags %}

<img src=”{% generate_thumbnail imagefile 200x300 %}”/> or <img src=”{% generate_thumbnail imagefile 100x100 crop %}”/>

Where imagefile is an object with at a property/field called: a) unique_filename or b) complete_filename or c) filename

Resolution is specified as <width>x<height>, for instance 640x480 and if you want to crop the photo add crop as shown in the example over.


  • django
  • PIL
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (21.4 kB) Copy SHA256 Checksum SHA256 Source May 9, 2011

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting