Resizing and cropping images via Nginx, and cache the result
Project description
Resizing and cropping images via Nginx, and cache the result
pip install django-nginx-image
For more details see:
http://github.com/adw0rd/django-nginx-image - the GitHub repository
http://pypi.python.org/pypi/django-nginx-image - the PyPI page
Settings:
Add to settings.py:
INSTALLED_APPS = ( 'nginx_image', )
Add to the configuration file of Nginx:
location ~* ^/resize/([\d\-]+)/([\d\-]+)/(.+)$ { alias <STORAGE_ROOT>/$3; image_filter resize $1 $2; image_filter_buffer 2M; error_page 415 = /empty; } location ~* ^/crop/([\d\-]+)/([\d\-]+)/(.+)$ { alias <STORAGE_ROOT>/$3; image_filter crop $1 $2; image_filter_buffer 2M; error_page 415 = /empty; } location = /empty { empty_gif; }
Using:
In the templates can be used as follows:
{% load nginx_image %} Proportionally resize a image, based on the width and the height: {% thumbnail user.profile.avatar 130 130 %} Proportionally resize a image, based on the width: {% thumbnail user.profile.avatar 130 '-' %} {% thumbnail user.profile.avatar 130 0 %} {% thumbnail user.profile.avatar 130 %} Proportionally resize a image, based on the height: {% thumbnail user.profile.avatar '-' 130 %} {% thumbnail user.profile.avatar 0 130 %} Crop a image: {% thumbnail user.profile.avatar 130 130 crop=1 %} {% thumbnail user.profile.avatar 130 0 crop=1 %} {% thumbnail user.profile.avatar 0 130 crop=1 %}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-nginx-image-0.1.tar.gz
.
File metadata
- Download URL: django-nginx-image-0.1.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18e7deaf53955d901a4356d99f255a4c3c4f2f09c0e6c3c05dc3a4be42a0cd89 |
|
MD5 | 0f11757bd574dc57e4a867c44d48adbe |
|
BLAKE2b-256 | b9962b1d83625d75fd31c871f796ae2d705cbc42a31762f5b17351f476a421de |