Skip to main content

Django Responsive Images

A Django app for resizing images and generating src and srcset values via template tags. It is intended to be very easy-to-use; just drop it in and use the template tags.

Requires Django and Pillow.

Installation

Install via pip:

pip install django-responsive-images

Then add responsive_images to your INSTALLED_APPS.

Usage

For the most part, this app is intended to be used via template tags. A demonstation of currently supported functionality follows:

{% load responsive_images %}

{# resize and crop an image attached to instance to fit 500x500 #}
<img src="{% src instance.image_field 500x500 %}">

{# resize (without cropping) to fit 500x500 #}
{# note: resulting size will likely not match both dimensions #}
<img src="{% src instance.image_field 500x500 nocrop %}">

{# specify crop position as percent: X,Y #}
<img src="{% src instance.image_field 500x500 50,20 %}">

{# center crop is the default, all of these are equivalent #}
<img src="{% src instance.image_field 500x500 %}">
<img src="{% src instance.image_field 500x500 crop %}">
<img src="{% src instance.image_field 500x500 center %}">
<img src="{% src instance.image_field 500x500 50,50 %}">

{# resize image multiple times and create srcset #}
<img srcset="{% srcset instance.field 400x400 800x800 1600x1600 %}">

{# srcset also allows nocrop and crop position #}
<img srcset="{% srcset instance.field 400x400 800x800 nocrop %}">
<img srcset="{% srcset instance.field 400x400 800x800 50,20 %}">

Note: If a specified size is larger than the source image in one or both dimensions, the resulting image will not match the specified size. Images will never be upscaled. The resulting image may be resized in only one dimension (if cropping) or it may return the original image. In either case, the srcset tag will output the correct width for the image used.

Metadata

Release files for django-responsive-images 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-responsive-images 1.3.0
File Size Uploaded
django-responsive-images-1.3.0.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-responsive-images 1.3.0
File Interpreter ABI Platform
django_responsive_images-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / django-responsive-images-1.3.0.tar.gz

Download URL django-responsive-images-1.3.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
11ce3a9c64701a7deebf634257174dae92a3af8fb55a91a9c4d71c543b9295fd
BLAKE2b-256 checksum
How to use checksums
e9ea1978216b35d04d5485e9260158d6a609fc17756ba69c547be9c0da17236b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / django_responsive_images-1.3.0-py3-none-any.whl

Download URL django_responsive_images-1.3.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
565043207181da65523b10668620cf27d2fc9136bb4a77e993fb31c8b6a2b3f3
BLAKE2b-256 checksum
How to use checksums
bf8d63af273779725b26062aa08ece93ccc0a178b8291de1c28ec67330161890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

1 release file

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page