URL-based image processing for Django
django-url-imaging provides URL-based image processing functionality for Django projects. It features a plugabble storage system with implementations for storing images locally, on Amazon S3 or using the SCP utiltiy to copy them to another server.
Once installed and configured, django-url-imaging will allow you to embed thumbnails and other image transformations using nothing more than a specially crafted URL. As an example, if you configured django-url-imaging to listen for requests on /thumbnails/ and needed to have a resized copy of the image at http://media.mydomain.com/foo.jpg, you would just create a link like:
<img src="/thumbnails/resize/50x50/media.mydomain.com/foo.jpg" />
django-url-imaging provides many different URL-based commands for image processing such as cropping, resizing, scaling, watermarking and much more. For more information on django-url-imaging, please check out the Wiki.
$ sudo python setup.py install
Depending on how you plan to store your images, you will need to add one of the following sets of properties to your settings.py file:
IMAGE_STORAGE_BACKEND – This parameter should be set to ‘LocalImageStorage’ for the local image storage backend.
IMAGE_WHITELIST_FN – A function which takes a url as an argument and uses that to decide whether or not to allow it to be processed. By default it is defined as lambda url: True which will allow for processing all images. To restrict it to only process images in your MEDIA_URL, set it to:
IMAGE_WHITELIST_FN = lambda url: settings.MEDIA_URL in url
IMAGE_STORAGE_DIR (optional) – The full path to the directory where images should be stored if this is not set, the value is inherited from MEDIA_ROOT. This directory should be publicly accessible since the application doesn’t serve images directly from it.
IMAGE_PATH_PREFIX (optional) - A path that is prepended to the path of the processed image.
If you’d like to use the scp command to copy the generated files to another UNIX-like server, configure the following options:
django-url-imaging adds the following custom command to the project’s django-admin: