Skip to content

bltravis/django-imageresize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django-imageresize

Introduction

Django-imageresize is an extension to the Django web framework that lets you resize images on server side just by specifying the size in the url. If you want to resize an image, foo.png, to 100×100 you simply just use the url foo.100x100.png which makes it very easy to create for example thumbnails.

The benefits of django-imageresize are:

  • Size is specified in link only, no dependecy on django templates
  • Images are resized using Imagemagick which delivers excellent quality
  • Resized images are cached on disk to improve performance.
  • No performance degradation after first resize if using content distribution networks like Akamai

Similar projects

There exists a lot of similar projects/snippets, some with plenty of more functions, but they tend to rely on the django template language which is something we wanted to avoid. Some examples:

Version history

0.1.1

  • Fixed settings.py conflict.
  • Fixed so that it is possible to scale images with no file ending

0.1

First version. Fully working, but not tested in a production environment.

Getting started

Install imagemagick

Download and install Imagemagick from Imagemagick official homepage

Install django-imageresize

For now you need to install from source. Download the source from GitHub’s downloads page.

In source directory run:

> easy_install .

Add the django-imageresize imageservice to your django application

Add the imageservice to the installed apps in your django application’s settings.py:

INSTALLED_APPS = (
    ... 
   'imageservice',
    ...
)

In same file, configure the cache root (this is where the resized images will be stored):


MEDIA_CACHE_ROOT = “/path/to/store/cached/images/”

And the max allowed size:


RESIZE_MAX_WIDTH = 2048
RESIZE_MAX_HEIGHT = 2048

About

Adds the possibility to create thumbnails and resize images on server side using imagemagick

Resources

License

Stars

Watchers

Forks

Packages

No packages published